legend

How to exclude series in legend (Flex)

时光总嘲笑我的痴心妄想 提交于 2019-12-04 08:23:52
In flex charting, I want to draw something like "reference lines" which are related to specific series, therefore these lines are not independent series and should not be shown in legend. Is it possible to exclude some series from chart legend? Thanks! I elaborated on Luis B's answer to make this dynamically reflect on the linechart's data provider. This way the legend only shows what fields are available in the chart. Kinda nifty. Here is what I came up with, and it works well: protected function onUpdateLinechartComplete(e:FlexEvent):void { //empty legend for fresh display var legendArray

Add legend to a plot with R

♀尐吖头ヾ 提交于 2019-12-04 07:58:27
I create 4 line in one plot using R . Here the code # Define 2 vectors cars <- c(123.07, 110.51, 96.14, 98.71, 101.3) trucks <- c(110.31, 89.91, 89.81, 89.31, 93.4, 95.81) cars1 <- c(123.227, 110.221, 93.14, 98.22, 122.3) trucks1 <- c(120.31, 89.91, 89.81, 89.31, 93.4, 95.81) # Graph cars using a y axis that ranges from 0 to 12 plot(cars, type="o", col="blue", ylim=c(80,130)) # Graph trucks with red dashed line and square points lines(trucks, type="o", pch=22, lty=2, col="red") lines(cars1, type="o", col="yellow", ylim=c(80,130)) # Graph trucks with red dashed line and square points lines

Merge legends of separate geom layers

帅比萌擦擦* 提交于 2019-12-04 06:00:14
问题 I am plotting point data from two separate layers on a map and would like to display the information of both layers in one legend. Here's some code to illustrate the problem: set.seed(42) lat1 <- rnorm(10, 54, 12) long1 <- rnorm(10, 44, 12) val1 <- rnorm(10, 10, 3) lat2 <- rnorm(10, 54, 12) long2 <- rnorm(10, 44, 12) val2 <- rnorm(10, 10, 3) df1 <- as.data.frame(cbind(long1, lat1, val1)) df2 <- as.data.frame(cbind(long2, lat2, val2)) library(ggplot2) library(scales) f <- ggplot() + geom_point

Horizontally align bar plot legends in python

 ̄綄美尐妖づ 提交于 2019-12-04 05:46:42
I have made a multi axis graph using the following code and I am unable to arrange the legend as I want. The code of my graph is as follows: import matplotlib.pyplot as plt import numpy as np x = np.arange(4) y = [5, 7, 4, 9] z = [9, 3, 5, 6] r = [30, 40, 45, 37] fig,ax = plt.subplots() abc = ax.bar(x,y,0.25 ) cde = ax.bar(x+0.25,z,0.25) ax.legend((abc[0], cde[0]), ('y', 'z'),bbox_to_anchor=(0., 1.02, 1, .102) , borderaxespad=0.) ax.set_xticks(x + 0.25 / 2) ax.set_xticklabels(('A', 'B', 'C', 'D')) ax2 = ax.twinx() efg = ax2.plot(x+0.25/2,r,color = 'black',label = "r") ax2.legend(bbox_to_anchor

Why ggplot2 legend not show in the graph

时光怂恿深爱的人放手 提交于 2019-12-04 04:15:34
问题 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))) +

creating legend for scatter3 plot (Matlab)

对着背影说爱祢 提交于 2019-12-04 03:55:06
问题 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> -

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

此生再无相见时 提交于 2019-12-04 03:54:29
问题 As this picture shows, how can I make these labels align right? I am using legend in R. 回答1: 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

Add NA value to ggplot legend for continuous data map

女生的网名这么多〃 提交于 2019-12-04 02:56:06
I'm using ggplot to map data values to a (fortified) SpatialPolygonsDataFrame, but many of the polygons have NA values because there is no data available. I used na.value = "white" to display the missing data correctly, but I'd like to add a box with a white fill in the legend (or a separate legend) with the label "no data". library(ggplot2) india.df <- read.csv('india.df.csv') # (I don't know how to provide this file to make the code reproducible) ggplot() + geom_polygon(data=india.df, aes(x = long, y = lat, group = group, fill=Area_pct)) + scale_fill_gradient(low="orange2", high="darkblue",

ggplot2 legend for abline and stat_smooth

孤街浪徒 提交于 2019-12-04 01:38:27
问题 I have some problems with ggplot legends, here is my first code with only the legend for corrGenes, which is fine. gene1=c(1.041,0.699,0.602,0.602,2.585,0.602,1.000,0.602,1.230,1.176,0.699,0.477,1.322) BIME = c(0.477,0.477,0.301,0.477,2.398,0.301,0.602,0.301,0.602,0.699,0.602,0.477,1.176) corrGenes=c(0.922,0.982,0.934,0.917,0.993,0.697,0.000,0.440,0.859,0.788,0.912,0.687,0.894) DF=data.frame(gene1,BIME,corrGenes) plot= ggplot(data=DF,aes(x=gene1,y=BIME))+ geom_point(aes(colour=corrGenes),size

Add legend outside of axes without rescaling in MATLAB

╄→гoц情女王★ 提交于 2019-12-04 01:30:53
I've got a GUI in MATLAB with a set of axes pre-placed. I'm using the location property of the legend to place it to the right hand side of the axes. However, by doing this the axes get re-scaled so that the axes+legend take up the original width of the axes. Is there any way to circumvent the re-size? Example: x=0:.1:10; y=sin(x); figure pos=get(gca,'position'); pos(3)=.5; %#re-size axes to leave room for legend set(gca,'position',pos) plot(x,y) So far I get: Place legend: legend('sin(x)','location','eastoutside') ...aaaaand... MATLAB squishes it all into the original axes space. Any way