legend

Add pch symbol in R plot legend

邮差的信 提交于 2019-12-03 05:07:44
I have one time series which is represented by a black line and one which is represented by a red curve. Then I have single points which have the pch symbol of 8 in R. These are stars. See the following plot: Currently I have the following legend: legend("bottomleft", legend=c("log loss","daily VaR","exceedance"), bty = "n",lwd=2, cex=1.2,y.intersp=1.4, col=c("black","red","blue"), lty=c(1,1,1)) But I don't want to have a blue line in the legend for exceedance, but just the stars in the plot. I have to use the pch=8. I just want to have the stars in the legend, not the stars with a line. So

Why won't my <legend> element display inline?

醉酒当歌 提交于 2019-12-03 04:26:29
I am trying to apply display: inline; to the <legend> element in my <fieldset> element, so that the following <span> will follow on the same line, but my CSS is having no effect. legend{ display: inline; } span { display: inline; } <fieldset> <legend>Legend</legend> <span>Follower</span> </fieldset> JSFiddle EDIT I have no control over the HTML; I can only edit CSS Legends are special. In particular, their default rendering can't be described in CSS, so browsers use non-CSS means of rendering them. What that means is that a statically positioned legend will be treated like a legend and be

R - Smoothing color and adding a legend to a scatterplot

好久不见. 提交于 2019-12-03 03:54:48
I have a scatterplot in R. Each (x,y) point is colored according to its z value. So you can think of each point as (x,y,z) , where (x,y) determines its position and z determines its color along a color gradient. I would like to add two things A legend on the right side showing the color gradient and what z values correspond to what colors I would like to smooth all the color using some type of interpolation, I assume. In other words, the entire plotting region (or at least most of it) should become colored so that it looks like a huge heatmap instead of a scatterplot. So, in the example below,

HighCharts Hide Series Name from the Legend

橙三吉。 提交于 2019-12-03 03:25:48
问题 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

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

北战南征 提交于 2019-12-03 03:06:41
问题 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:

Matplotlib: Adjust legend location/position

我只是一个虾纸丫 提交于 2019-12-03 02:30:30
I'm creating a figure with multiple subplots. One of these subplots is giving me some trouble, as none of the axes corners or centers are free (or can be freed up) for placing the legend. What I'd like to do is to have the legend placed somewhere in between the 'upper left' and 'center left' locations, while keeping the padding between it and the y-axis equal to the legends in the other subplots (that are placed using one of the predefined legend location keywords). I know I can specify a custom position by using loc=(x,y) , but then I can't figure out how to get the padding between the legend

Text alignment in a Matplotlib legend

浪尽此生 提交于 2019-12-03 01:59:37
I am trying to right-align the entries in a matplotlib axes legend (by default they are left-aligned), but can't seem to find any way of doing this. The setup I have is below: (I have added data and labels to my_fig axes using the ax.plot() command) ax = my_fig.get_axes()[0] legend_font = FontProperties(size=10) ax.legend(prop=legend_font, num_points=1, markerscale=0.5) There is a list of legend keyword arguments in the docs for matplotlib Axes , but there doesn't seem to be any straighforward way to set the alignment of the legend entries there. Anybody know of a backdoor way of doing this?

Show only certain items in legend Python Matplotlib

旧城冷巷雨未停 提交于 2019-12-03 01:19:15
问题 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

Matplotlib automatic legend outside plot [duplicate]

陌路散爱 提交于 2019-12-02 20:40:57
This question already has answers here : How to put the legend out of the plot (16 answers) I am trying to use the keyword bbox_to_anchor() in a matplotlib plot in Python. Here is a very basic plot that I have produced: import matplotlib.pyplot as plt x = [1,2,3] plt.subplot(211) plt.plot(x, label="test1") plt.plot([3,2,1], label="test2") plt.legend(bbox_to_anchor=(0, -0.15, 1, 0), loc=2, ncol=2, mode="expand", borderaxespad=0) plt.show() It is based on the example here: http://matplotlib.org/users/legend_guide.html#plotting-guide-legend I am trying to automatically place the legend outside

How can I control the placement of my Chart.JS pie chart's legend, as well as its appearance?

你离开我真会死。 提交于 2019-12-02 20:30:44
I am able to create a pie chart using Chart.JS with this code: HTML <div> <canvas id="top10ItemsChart" style="padding-left:20px" width="320" height="320"></canvas> <div id="top10Legend" class="chart-legend"></div> </div> jQuery var data = [{ value: 2755, color: "#FFE135", label: "Bananas" }, { value: 2256, color: "#3B5323", label: "Lettuce, Romaine" }, { value: 1637, color: "#fc6c85", label: "Melons, Watermelon" }, { value: 1608, color: "#ffec89", label: "Pineapple" }, { value: 1603, color: "#021c3d", label: "Berries" }, { value: 1433, color: "#3B5323", label: "Lettuce, Spring Mix" }, { value: