legend

r legend trouble , how to change the text size in legend

让人想犯罪 __ 提交于 2019-12-02 20:20:59
I think cex doesn't work. Cex will change the whole scale of the legend. But I just want to enlarge the text size. any command will help? Yes!, set pt.cex = 1 and change cex as you want as in: plot(c(1,1)) legend("topleft", "Legend", cex=1.3, pch=1, pt.cex = 1) You can set the cex for the points separately from the rest of the legend. This would still make the box small, though. A more specific example of what you're trying to do might help. However, see if this solves your problem: plot(rnorm(10)) legend("top", legend="test", pch=21) #everything is normal sized (cex=1 default from par())

plot functions with filled point symbols and legend

房东的猫 提交于 2019-12-02 18:57:50
I want to plot two functions in different colors and point styles with a corresponding legend, in plain R . I have several questions: I am using pch=21 and pch=22 . My understanding is that they are "filled" symbols. They do appear filled as expected in the legend, but they appear hollow on the graph itself. What's wrong? Can I get more space between the points without specifying a grid manually? maybe by selecting the number of points to be printed? Feel free to add any kind of advice you'd like. I'm very new to R. In particular, is there a better way to plot two functions? e.g. by defining

how to show legend items of patches in bokeh

穿精又带淫゛_ 提交于 2019-12-02 18:37:52
问题 In the following set up, I create a area chart based on the basic example. How do I get the legend for my input automatically or even programatically. For now I get only legend with one item 'a' and the first color. from bokeh.plotting import * ... patches([x2 for a in areas], list(areas.values()), color=colors, alpha=0.8, line_color=None, legend='a', title="hello chart") legend().orientation = "top_right" # what other options, may here? show() What is the format to pass into patches for the

Adjust spacing between text in horizontal legend

泪湿孤枕 提交于 2019-12-02 18:28:13
I have a plot with a horizontal legend: legend("bottomleft", inset = c(0, -0.3), bty = "n", x.intersp=0, xjust=0,yjust=0, legend=c("AAPL", "Information Technology", "Technology Hardware and Equipment", "S&P 500"), col=c("black", "red", "blue3", "olivedrab3"), lwd=2, cex = 0.5, xpd = TRUE, ncol = 4) The problem is that there is a huge spacing between the first item of the legend, "AAPL", and the second item "Information Technology". I tried adjusting the spacing using txt.width() , but it didn't work at all. Or maybe I am not using this option as directed. This is how I have introduced the txt

Pandas bar plot with specific colors and legend location?

五迷三道 提交于 2019-12-02 18:01:11
I have a pandas DataFrame and I want to plot a bar chart that includes a legend. import pylab as pl from pandas import * x = DataFrame({"Alpha": Series({1: 1, 2: 3, 3:2.5}), "Beta": Series({1: 2, 2: 2, 3:3.5})}) If I call plot directly, then it puts the legend above the plot: x.plot(kind="bar") If I turn of the legend in the plot and try to add it later, then it doesn't retain the colors associated with the two columns in the DataFrame (see below): x.plot(kind="bar", legend=False) l = pl.legend(('Alpha','Beta'), loc='best') What's the right way to include a legend in a matplotlib plot from a

R: legend with points and lines being different colors (for the same legend item)

萝らか妹 提交于 2019-12-02 17:39:48
Using the legend() function is it possible to have the point and line be different colors? I feel like I'm missing something fairly obvious. The pt.bg option can change the background color, but I'm not seeing a pt.fg option The arises in the case when you use the lines() and points() command separately with different colors and want the legend to represent what is plotted. I thought it might be possible with the merge options, but I clearly don't quite understand what that is for. Example: plot( 0, type="n", xlim=c(0,5), ylim=c(0,5) ) A <- matrix( c( c(1,2,3,4), c(2,1,2,4)), ncol=2 ) B <-

HighCharts Hide Series Name from the Legend

拜拜、爱过 提交于 2019-12-02 16:55:19
I try to solve this problem several times and give up. Now, when I have met him again, I decided to ask for some help. I have this code for my Legend: legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: -10, y: 100, borderWidth: 0, labelFormatter: function() { if(this.name!='Series 1') { return this.name; } else { return 'Legend'; } } } If I change the return from 'Legend' to '' the text is not shown but still there is a 'dash' on the top of the legend. If I do not use label formater function I have 'Series 1' + 'dash' like a first row in my legend. How to hide them? Please,

Show only certain items in legend Python Matplotlib

纵饮孤独 提交于 2019-12-02 15:04:24
I currently am plotting a stacked bar graph of a large amount of taxonomic data, and only wish to show significant species in the legend (out of ~500 I wish to show ~25). Is there a simple way to do this? Below is the code I have: labels=['0','20','40','60','80','100','120'] ax1=subj1df.plot(kind='barh', stacked=True,legend=True,cmap='Paired', grid=False) legend(ncol=2,loc=2, bbox_to_anchor=(1.05, 1), borderaxespad=0.) label1=['Baseline','8h','24h','48h','96h','120h'] ax1.set_yticklabels(label1, fontdict=None, minor=False) plt.title('Subject 1 Phyla',fontweight='bold') plt.savefig(

How to adjust the size of matplotlib legend box?

拥有回忆 提交于 2019-12-02 14:19:12
I have a graph whose left upper corner is quite blank. So I decide to put my legend box there. However, I find the items in legend are very small and the legend box itself is also quite small . By "small", I mean something like this How can I make the items ( not texts! ) in the legend box bigger? How can i make the box itself bigger? To control the padding inside the legend (effectively making the legend box bigger) use the borderpad kwarg. For example, here's the default: import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 100) fig, ax = plt.subplots() for i in range(1,

How do I display only selected items in a ggplot2 legend? [duplicate]

…衆ロ難τιáo~ 提交于 2019-12-02 12:42:14
问题 This question already has an answer here : Remove legend entries for some factors levels (1 answer) Closed 4 years ago . I'm creating a stacked bar plot of relative abundance data, but I only want to display the ten most abundant organisms in the legend. How do I do this? I have no idea where to begin and haven't found any answers online. Here's the plot with a full legend: Thanks. 回答1: As pointed out by user20650 in the comments, the answer is to add a list of selected items to the breaks=