legend

Draw a Legend to an empty ggplot [duplicate]

会有一股神秘感。 提交于 2021-01-28 04:09:36
问题 This question already has answers here : How to plot just the legends in ggplot2? (4 answers) Closed 2 years ago . Is it possible to create a empty ggplot with no data, but draw a legend based on defined values in R? So the image created is simply the legend? Originally I thought I could plot the data and print a white rectangle over it, but given that not every background is white, it is unrealistic. I have tried the below, but it looks like ggplot wants some dataframe, therefore I had to

R ggplot heatmap with multiple rows having separate legends on the same graph

跟風遠走 提交于 2021-01-27 20:07:00
问题 I'm trying to make one heatmap using ggplot2 that contains 3 types of variables where each need their own independent legend/scale. I am able to plot them all in one heatmap (pictured below), but I am having trouble separating them to have their own legend. My three categories are the row "Score", "samp1" and the rest of the data. I would like each of these to have their own independent legends with their respective ranges. My only addition would be to have the row score have a green,yellow

How can I add a geom_quantile legend to this customized facet_wrap?

强颜欢笑 提交于 2021-01-27 19:43:36
问题 I recently received great help from SO in producing this customized facet_wrap -plot shown below. Question: how can I add the dotted linetype used in geom_quantile(linetype=2) as legend with the text "50th percentile"? I have sought solutions in similar questions on SO, but my question has not been answered. My current plot looks like this Produced with the following code cols = c("#E1B930", "#2C77BF","#E38072","#6DBCC3") ggplot(p, aes(x=n.fjernet,y=os.neck)) + geom_point(aes(color=uiccc)

Increase size of symbols in the matplotlib legend?

人盡茶涼 提交于 2021-01-24 07:16:37
问题 I draw a plot with markers like so: plt.scatter(xs1, ys1, s=12, linewidths=0, marker='o', label='hello') plt.scatter(xs2, ys2, s=12, linewidths=0, marker='x', label='hello') this produces the right size in the graph, but the symbols are hardly intelligible in the legend. How can I increase the size of the symbols in the legend ? 回答1: I found the solution in matplotlib.pyplot.legend. The legend takes an attribue 'markerscale'. plt.legend(loc='best',markerscale=2) 来源: https://stackoverflow.com

Increase size of symbols in the matplotlib legend?

亡梦爱人 提交于 2021-01-24 07:14:11
问题 I draw a plot with markers like so: plt.scatter(xs1, ys1, s=12, linewidths=0, marker='o', label='hello') plt.scatter(xs2, ys2, s=12, linewidths=0, marker='x', label='hello') this produces the right size in the graph, but the symbols are hardly intelligible in the legend. How can I increase the size of the symbols in the legend ? 回答1: I found the solution in matplotlib.pyplot.legend. The legend takes an attribue 'markerscale'. plt.legend(loc='best',markerscale=2) 来源: https://stackoverflow.com

How to clear matplotlib labels in legend?

柔情痞子 提交于 2021-01-02 06:31:25
问题 Is there a way to clear matplotlib labels inside a graph's legend? This post explains how to remove the legend itself, but the labels themselves still remain, and appear again if you plot a new figure. I tried the following code, but it does not work: handles, labels = ax.get_legend_handles_labels() labels = [] EDIT: Here is an example import matplotlib.pyplot as plt fig = plt.figure() ax = fig.gca() ax.scatter([1,2,3], [4,5,6], label = "a") legend = ax.legend() plt.show() legend.remove()

Unable to show legend in seaborn distplot

本秂侑毒 提交于 2020-12-29 02:11:01
问题 I am new to plotting in python and trying following code to plot distribution in seaborn but unable to see the legend, i.e., test_label1 and test_label1 on the plot. import matplotlib.pylab as plt import seaborn as sns import numpy as np plt.figure("Test Plots") lst1 = list(np.random.rand(10)) lst2 = list(np.random.rand(10)) sns.distplot(lst1, label='test_label1', color="0.25") sns.distplot(lst2, label='test_label2', color="0.25") plt.show() 回答1: As you have already labelled your plots using

Unable to show legend in seaborn distplot

社会主义新天地 提交于 2020-12-29 01:59:41
问题 I am new to plotting in python and trying following code to plot distribution in seaborn but unable to see the legend, i.e., test_label1 and test_label1 on the plot. import matplotlib.pylab as plt import seaborn as sns import numpy as np plt.figure("Test Plots") lst1 = list(np.random.rand(10)) lst2 = list(np.random.rand(10)) sns.distplot(lst1, label='test_label1', color="0.25") sns.distplot(lst2, label='test_label2', color="0.25") plt.show() 回答1: As you have already labelled your plots using

Unable to show legend in seaborn distplot

喜夏-厌秋 提交于 2020-12-29 01:59:07
问题 I am new to plotting in python and trying following code to plot distribution in seaborn but unable to see the legend, i.e., test_label1 and test_label1 on the plot. import matplotlib.pylab as plt import seaborn as sns import numpy as np plt.figure("Test Plots") lst1 = list(np.random.rand(10)) lst2 = list(np.random.rand(10)) sns.distplot(lst1, label='test_label1', color="0.25") sns.distplot(lst2, label='test_label2', color="0.25") plt.show() 回答1: As you have already labelled your plots using

Unable to show legend in seaborn distplot

北城余情 提交于 2020-12-29 01:58:07
问题 I am new to plotting in python and trying following code to plot distribution in seaborn but unable to see the legend, i.e., test_label1 and test_label1 on the plot. import matplotlib.pylab as plt import seaborn as sns import numpy as np plt.figure("Test Plots") lst1 = list(np.random.rand(10)) lst2 = list(np.random.rand(10)) sns.distplot(lst1, label='test_label1', color="0.25") sns.distplot(lst2, label='test_label2', color="0.25") plt.show() 回答1: As you have already labelled your plots using