legend

How can I change the color of the plot in each iteration in MATLAB?

女生的网名这么多〃 提交于 2019-12-01 19:51:53
问题 The following is a part of my matlab code. As it's shown, I would like to plot 8 curves in one plot. But I want to make each curve with one unique color. I also want to change the legend so that it changes for each i . For instance, for i=1 the legend will be gho-1, for i=2 gho-2 and so on. I want it to be automatic because I will change the i sometimes from ex:(i=1:20). for i=1:8 . . . plot(b,r,'b'); legend(['qho-',num2str(i)]); hold on end How can I do this? Hi again, I have other question:

How to make labels in the legend align right in R?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 19:31:47
As this picture shows, how can I make these labels align right? I am using legend in R. From ?legend ## right-justifying a set of labels: thanks to Uwe Ligges x <- 1:5; y1 <- 1/x; y2 <- 2/x plot(rep(x, 2), c(y1, y2), type = "n", xlab = "x", ylab = "y") lines(x, y1); lines(x, y2, lty = 2) temp <- legend("topright", legend = c(" ", " "), text.width = strwidth("1,000,000"), lty = 1:2, xjust = 1, yjust = 1, title = "Line Types") text(temp$rect$left + temp$rect$w, temp$text$y, c("1,000", "1,000,000"), pos = 2) EDIT: I can't find a way to automatically align the legend with the lines on the right.

JFreeChart Legend Display

喜你入骨 提交于 2019-12-01 19:24:20
问题 In my JFreeChart timeseries plots I find the legends lines to thin to see the colour accurately. Another post [ jfreechart - change sample of colors in legend ] suggested overriding a renderer method as follows: renderer = new XYLineAndShapeRenderer() { private static final long serialVersionUID = 1L; public Shape lookupLegendShape(int series) { return new Rectangle(15, 15); } }; this approach works fine until you do what I did renderer.setSeriesShapesVisible(i, false); Once I did that the

creating legend for scatter3 plot (Matlab)

故事扮演 提交于 2019-12-01 19:04:03
I have a matrix points X in 3 dimensions ( X is a Nx3 matrix) and those points belong to clusters. The cluster it belongs is given by the Nx1 vector Cluster (it has values like 1,2,3,...). So, I am plotting it on scatter3 like this: scatter3(X(:,1),X(:,2),X(:,3),15,Cluster) It works fine, but I would like to add a legend to it, showing the colored markers and the cluster it represents. For example, if i have 3 clusters, I would like to have a legend like: <blue o> - Cluster 1 <red o> - Cluster 2 <yellow o> - Cluster 3 Thank you very much for the help! Jonas Instead of using scatter3 , I

Why ggplot2 legend not show in the graph

﹥>﹥吖頭↗ 提交于 2019-12-01 18:29:52
I use ggplot to scatterplot 2 datasets and want to show the legend in the top left. I tried some code but didn't work. I am not sure why this happened. ggplot(mf, aes(log10(mf[,2]),mf[,1])) + ggtitle("Plot") + geom_point(color = "blue") + theme(plot.margin = unit(c(1,2,1,1), "cm")) + xlab("xxx") + ylab("yyy") + theme(plot.title = element_text(size=18,hjust = 0.5, vjust=4)) + geom_point(data=mf2,aes(log10(mf2[,2]),mf2[,1]),color="red") + theme(axis.title.x = element_text(size = rel(1.3))) + theme(axis.title.y = element_text(size = rel(1.3))) + scale_color_discrete(name = "Dataset",labels = c(

ggplot2: Change legend symbol

别来无恙 提交于 2019-12-01 18:03:18
I have plotted several lines and I am wondering how to change the symbol in the legend to go from the thin line to a full block. I am trying to go from to (while using geom_line and not geom_bar) You can use function guides() and then with argument override.aes= set line size= (width) to some large value. To remove the grey area around the legend keys set fill=NA for legend.key= inside theme() . df<-data.frame(x=rep(1:5,each=3),y=1:15,group=rep(c("A","B","C"),each=5)) ggplot(df,aes(x,y,color=group,fill=group))+geom_line()+ guides(colour = guide_legend(override.aes = list(size = 10)))+ theme

Is header in legend valid? <legend><h1>Caption</h1></legend>

我只是一个虾纸丫 提交于 2019-12-01 16:58:51
I use this in visual studio but the compiler claimed that h1 cannot be nested in legend element, but browser can render it anyway so i am confused that this is valid or not? <fieldset> <legend> <h1>Caption</h1> </legend> </fieldset> There are many things that browsers do that aren't required by the standards :-) This page here (HTML4) specifies the legend keyword and states that it can contain inline elements , of which the headers are not a part. It does have other possibly useful ones such as big or strong . In addition, the relevant page for H1 does not list legend as one of the items it's

ggplot2: Change legend symbol

人走茶凉 提交于 2019-12-01 16:35:17
问题 I have plotted several lines and I am wondering how to change the symbol in the legend to go from the thin line to a full block. I am trying to go from to (while using geom_line and not geom_bar) 回答1: You can use function guides() and then with argument override.aes= set line size= (width) to some large value. To remove the grey area around the legend keys set fill=NA for legend.key= inside theme() . df<-data.frame(x=rep(1:5,each=3),y=1:15,group=rep(c("A","B","C"),each=5)) ggplot(df,aes(x,y

Is header in legend valid? <legend><h1>Caption</h1></legend>

故事扮演 提交于 2019-12-01 15:03:48
问题 I use this in visual studio but the compiler claimed that h1 cannot be nested in legend element, but browser can render it anyway so i am confused that this is valid or not? <fieldset> <legend> <h1>Caption</h1> </legend> </fieldset> 回答1: There are many things that browsers do that aren't required by the standards :-) This page here (HTML4) specifies the legend keyword and states that it can contain inline elements, of which the headers are not a part. It does have other possibly useful ones

AttributeError: Unknown property legend in seaborn

随声附和 提交于 2019-12-01 15:00:50
The seaborn stripplot has a function which allows hue . Using the example from https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.stripplot.html import seaborn as sns sns.set_style("whitegrid") tips = sns.load_dataset("tips") ax = sns.stripplot(x=tips["total_bill"]) ax = sns.stripplot(x="sex", y="total_bill", hue="day", data=tips, jitter=True) In this case, the legend is quite small, showing a different hue for each day. However, I would like to remove the legend. Normally, one includes a parameter legend=False . However, for stripplot , this appears to output an attribute error: