legend

How to remove lines from legends in ggplot?

孤街醉人 提交于 2019-12-11 06:57:40
问题 I've read a few posts about this, but didn't find the right solution for my problem. Because the dashed line from geom_vline is vertical, it's also shown that way in the legend. On top of that, the short-dashed lines also get a vertical partner which is really not necessary. Is it possible to get only horizontal lines for both the colours and the types? It would make the legend much clearer. As my code is based on a large dataset, I made a simple short variant to show here. # data (example)

How to add legend to scatter plot that has colour assignment

梦想与她 提交于 2019-12-11 06:39:07
问题 I have an a list of x and y values and list of colour assignments for each point ('green', 'blue', 'red', etc). All of the examples I have found produce a legend based on separate plt.scatter() commands which later a simple plt.legend() suffices. making matplotlib scatter plots from dataframes in Python's pandas. My scatter does not have separate scatters for each coloured group. So how do I produce a legend that shows the colours of each group? import matplotlib.pyplot as plt colors = ["red"

Create a Highcharts Pie Chart Legend Inside a Table

牧云@^-^@ 提交于 2019-12-11 06:15:52
问题 Is there a way to create a Highcharts legend inside of a table? I want to be able to style the background of the legend for my Highcharts pie with alternating background colors for each element and custom borders. I've formatted my legend like so, but cannot figure out how to embed it inside a table that I can then format. legend: { layout: 'vertical', align: 'center', verticalAlign: 'bottom', backgroundColor: '#f3f3f3', borderWidth: 0, useHTML: true, itemMarginBottom: 10, labelFormatter:

Can you add a legend to a dc.js Bubble Chart?

爷,独闯天下 提交于 2019-12-11 06:02:24
问题 Is it possible to make a legend for Bubble Chart? Somebody asked this question a few years ago, but I cannot find a good answer for it. Does anybody have an example of where they made a legend for a bubble chart using dc.js? 回答1: You can manually add legend support to any chart which does not have it already by defining the .legendables() function. Although many charts (e.g. pie, line, bar, scatter, sunburst) support it, the default is to return an empty array. One reason why it might not be

Align symbols in the legend

断了今生、忘了曾经 提交于 2019-12-11 05:49:23
问题 I woult like to insert a legent to my plot. I tried this with the following code: plot(1:4) legend("topleft",legend=expression(paste(theta[1]==7%*%10^-4,sep=" ",theta[2]==-14%*%10^-4), paste(theta[1]==0,sep=" ",theta[2]==0)),bty="n",cex=1.2) Unfortunately, as you can see, the symbols of the legend are not not aligned in the vertical sence. So theta_2 in the second line appears under the value of theta_1 of the first line. How can I change the code, so that the symbols are well aligned? 回答1:

how to include in legend symbol of mean in boxplot with ggplot?

元气小坏坏 提交于 2019-12-11 05:19:30
问题 I would like to have in the legend the symbol of the mean together with the symbols of the boxes. So my legend should include "Exposure 1, Exposure 2, Exposure 3" but also the word mean and its symbol. How to do this using ggplot in R? This is the code I'm using to produce the boxplot: library(ggplot2) mydata <- read.csv("~/mydata.csv") bp<-ggplot(mydata,aes(x=Category,y=MeanValues,,fill=as.factor(Category))) + geom_boxplot() bp+labs(x = NULL, y = "Result")+ theme_bw()+stat_summary(fun.y =

Add colorbar as legend to matplotlib scatterplot (multiple subplots, multiple scatters)

本秂侑毒 提交于 2019-12-11 04:59:35
问题 I have several subplots to which I want to add a single colorbar. Each subplot consists of 7 scatters. I found advise on how to add colorbars, but they are mostly related to the value of each scatter-point and not to the row itself. Representative sample code: import numpy as np from matplotlib import pyplot as plt x = range(50) scales = np.linspace(0, 2, 7) locs = range(4) cmap = plt.get_cmap("Spectral") for s_plot in range(4): plt.subplot(2, 2, s_plot+1) color = iter(cmap(np.linspace(0, 1,

How to change legend label in “theme” argument in ggplot2?

青春壹個敷衍的年華 提交于 2019-12-11 03:59:24
问题 I am using ggplot2 ro draw error bar plot. For the legend, I want it like this: inside the plot. I know function theme(legend.position) can do this. use latex symbol in the legend labels with function expression. I have read several references of constructing the legend, but still have not found what I want exactly. I can perform either 1 or 2, but can not do both in my plot. Following is R code of the plot with the problem. Since my reputation is not enough to post an image, please copy the

R legend issue, symbols of points are masked by lines

☆樱花仙子☆ 提交于 2019-12-11 03:45:45
问题 Is there a way to draw the lines in such a way that they would start on the side of the points, or allow the symbols to be in foreground? My solution was to make the symbols bigger and more visible. Edit 1: it's for plot {graphics} of the R program. Edit 2: the code per popular request. legend(2,.4,bty='n', c('sugar','citrus','none'), pch=c('s','c','u'), pt.bg='white',lty= c(1,2,3), lwd=1.5, title="Condition",pt.cex=c(1.5),cex=1.5) Edit 3: This is solved for plot(type='b') but somehow not for

how to change the sequence of the legend

大兔子大兔子 提交于 2019-12-11 03:13:59
问题 I want to change the sequence of the legend. See the figure. I want the sequence to be: green and data2 , blue and data3 , black and data4 , red and data1 . Could anyone give a demo? 回答1: Change the order in which the plots are added to the figure, and then call legend normally. That should do it. You can also do it as follows. First get handles to the individual plots: h1 = plot(1:5); hold on h2 = plot(11:15, 'r'); Then call legend specifying the order: legend([h1 h2],'plot1','plot2') or