# Problem with legend labels with ggplotly function

**URL:** <https://community.plotly.com/t/problem-with-legend-labels-with-ggplotly-function/2543>\
**Category:** Plotly R\
**Created:** [October 28, 2016, 12:17am UTC](https://community.plotly.com/t/problem-with-legend-labels-with-ggplotly-function/2543 "2016-10-28T00:17:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jason](https://community.plotly.com/u/Jason)\
**Post date:** [October 28, 2016, 12:17am UTC](https://community.plotly.com/t/problem-with-legend-labels-with-ggplotly-function/2543/1 "2016-10-28T00:17:50Z")

</div>

Hello people,

im relatively new with plotly and it looks quite exciting !! recently, i was trying through Rstudio and from package ggplot2,  
to create an interactive pca plot (regarding some gene expression data) using as final function the ggplotly function. In detail, part of my code:

mat ← exprs(eset.4) # one expression set for input  
pca ← prcomp(t(mat), scale=TRUE)  
pcvar = pca$sdev^2/sum(pca$sdev^2)\*100  
tot ← cbind(pca$x,phenotype\_dat) # which renders the variables info

p ← ggplot(tot, aes(PC1,PC2, colour=Disease,shape=Study)  
p ← p + geom\_point(size=3) +  
xlab(paste0(“PC1: “,round(pcvar[1],2),”% variance”)) +  
ylab(paste0(“PC2: “,round(pcvar[2],2),”% variance”))

> ggplotly(p)

The only problem is that the legend labels in the output image are not clear and well separated !!  
Is there a way to fix this in the above implementation with ggplotly ?

Thank you in advance,

Efstathios-Iason

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/c8a4bb643345ccf5a1169f5d16a524fbd9868626.png)
