legend

How to increase the font size of the legend in my Seaborn plot?

对着背影说爱祢 提交于 2019-12-03 09:58:55
问题 I have the following codes to create a Seaborn strip plot. I am having a hard time figuring out how to increase the font size of the legend appearing in the plot. g=sns.stripplot(x="Market", y="Rate", hue="Group",data=myBenchmarkData, jitter=True, size=12, alpha=0.5) g.axes.set_title("4* Rate Market and by Hotel Groups for Year 2016",fontsize=25) g.set_xlabel("Market",fontsize=20) g.set_ylabel("Rate (in EUR)",fontsize=20) g.tick_params(labelsize=15) plt.savefig ('benchmark1.png') I am OK with

How to add a legend for two geom layers in one ggplot2 plot?

扶醉桌前 提交于 2019-12-03 08:35:08
I've got a data frame that looks like this: glimpse(spottingIntensityByMonth) # Observations: 27 # Variables: 3 # $ yearMonth <dttm> 2015-05-01, 2015-06-01, 2015-07-01, 2015-08-01, 2015-09-01, 2015-10-01, 2... # $ nClassificationsPerDayPerSpotter <dbl> 3.322581, 13.212500, 13.621701, 6.194700, 18.127778, 12.539589, 8.659722, ... # $ nSpotters <int> 8, 8, 22, 28, 24, 22, 24, 27, 25, 29, 32, 32, 21, 14, 18, 13, 20, 19, 15, ... I am trying to plot it with ggplot2 like so: ggplot() + geom_col(data = spottingIntensityByMonth, mapping = aes(x = yearMonth, y = nClassificationsPerDayPerSpotter) ) +

Superscript R squared for legend

放肆的年华 提交于 2019-12-03 08:19:02
I want to write a R-squared term for my legend but I do not know how. Could someone help me please? My legend syntax is: legend(2,10, c("BW (MPE=3%, R-squared=0.77)", "MY (MPE=5%, R-squared=0.80)", pch=c(2,3)) I would liek to express R-squared as R2 as we normally have in the text. It will work if you combine bquote and as.expression : plot(1:10) legend(2, 10, c(as.expression(bquote("BW (MPE = 3%," ~ R^2 ~ "= 0.77)")), as.expression(bquote("MY (MPE = 5%," ~ R^2 ~ "= 0.80)"))), pch=c(2,3)) This is less complex than using c( as.expression ( bquote... multiple times: plot(1:10) legend(2, 10,

Matplotlib automatic legend outside plot [duplicate]

南楼画角 提交于 2019-12-03 07:08:14
问题 This question already has answers here : How to put the legend out of the plot (16 answers) Closed 2 years ago . 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:

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

空扰寡人 提交于 2019-12-03 06:53:22
问题 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: "

JQPlot Legend outside of graph

蹲街弑〆低调 提交于 2019-12-03 06:45:27
I am using JQPlot and I have many graphs on one HTML page. Each of the graphs has the same legend. My question is this: Is it possible to display a legend totally outside of the graph with its own position on the HTML page or in its own div? legend:{ show:true, renderer: $.jqplot.EnhancedLegendRenderer, location: 's' , placement : "outside", marginTop : "30px", rendererOptions: { numberRows: 1 } }, You can use placement : "outside" like in the above code. And you can move it using marginTop,marginBottom,marginRight,marginLeft properties. Maybe you could hide the legend of the 2nd to the last

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

ε祈祈猫儿з 提交于 2019-12-03 06:42:00
问题 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? 回答1: 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) 回答2: 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:

How to make two markers share the same label in the legend using matplotlib?

跟風遠走 提交于 2019-12-03 06:19:06
What I want is like this: What I get is this: So how to merge the markers into one label? also for the lines, for the lines, of course, u can realize it by not assigning label to the second line while using the same linetype, but for the markers, you can not, since they are of different shapes. I think it's best to use a full legend - otherwise, how will your readers know the difference between the two models, or the two datasets? I would do it this way: But, if you really want to do it your way, you can use a custom legend as shown in this guide . You'll need to create your own class, like

Adjust spacing between text in horizontal legend

不羁岁月 提交于 2019-12-03 05:57:21
问题 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

How to wrap legend items in highcharts?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 05:33:58
I have a big problem using highcharts, because I have been trying for hours to wrap legend items if they very long. I have tried to set legend and legend item width, but my text still get out from a legend. Only thing that I found is to change highcharts.src.js but I think that's not a way to solve this problem. Here my code: <script type="text/javascript"> var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'graph_container', defaultSeriesType: 'line', zoomType: 'y', marginRight: 130, marginBottom: $ { marginBottom } }, title: { x: -10, text: null },