legend

Getting an object in Python Matplotlib

杀马特。学长 韩版系。学妹 提交于 2020-02-23 08:10:31
问题 To make a plot, I have written my code in the following fashion: from pylab import * x = [1,2,3] y = [1,2,3] matplotlib.pyplot.scatter(x,y,label='Blah') matplotlib.pyplot.legend(title='Title') matplotlib.pyplot.show() I want to change the font size of the legend title. The way to go about this is to get the legend object and then change the title that way (e.g., How to set font size of Matplotlib axis Legend?) Instead of rewriting all my code using ax.XXX, figure.XXX, etc, is there any way to

Getting an object in Python Matplotlib

送分小仙女□ 提交于 2020-02-23 08:10:30
问题 To make a plot, I have written my code in the following fashion: from pylab import * x = [1,2,3] y = [1,2,3] matplotlib.pyplot.scatter(x,y,label='Blah') matplotlib.pyplot.legend(title='Title') matplotlib.pyplot.show() I want to change the font size of the legend title. The way to go about this is to get the legend object and then change the title that way (e.g., How to set font size of Matplotlib axis Legend?) Instead of rewriting all my code using ax.XXX, figure.XXX, etc, is there any way to

d3js - error in rendering a legend key - duplicated render?

人盡茶涼 提交于 2020-02-23 06:48:29
问题 I am trying to complete a timeline application - - but I am getting a malfunction with the region key area latest fiddle https://jsfiddle.net/fqn4vb90/2/ when this gets rendered -- they all seem to be duplicates of the first array element? So in this example -- first element is JA, the second should be AS, and the third should be E let listRegions = [{ "label" : "A", "value" : "SIEA" },{ "label" : "E", "value" : "SIEE" },{ "label" : "JA", "value" : "SIEJA-JAPAN" },{ "label" : "AS", "value" :

Placing legend above main title

眉间皱痕 提交于 2020-02-15 07:59:27
问题 Placing the legend above the main title in ggplot2 when using theme(legend.position = "top") seemed to be the default (and unwanted) outcome in previous versions of ggplot: ggplot legend at top but below title? In the current version of ggplot2 , the legend places itself between the plot and the main title when setting theme(legend.position = "top") . A small example: d <- data.frame(x = 1:2, y = 1:2, z = c("a", "b")) ggplot(d, aes(x = x, y = y, fill = z)) + geom_col() + ggtitle("My title") +

Add legend to ggplot histogram with different types of aesthetics

不打扰是莪最后的温柔 提交于 2020-02-02 08:23:08
问题 I want to add a legend to one of my plots, but I have different aesthetics and I never created a legend so I find it very difficult to determine how to build it. One of my aesthetics is a fill code, which I added manually as a vector. The other aesthetic is a vertical line that I added with geom_vline. From the graph below, there are three characteristics that I want to add to the legend: 1) The bars with color dark blue, 2) The bars with color light blue and 3) The vertical line. Does anyone

Add legend to ggplot histogram with different types of aesthetics

主宰稳场 提交于 2020-02-02 08:22:06
问题 I want to add a legend to one of my plots, but I have different aesthetics and I never created a legend so I find it very difficult to determine how to build it. One of my aesthetics is a fill code, which I added manually as a vector. The other aesthetic is a vertical line that I added with geom_vline. From the graph below, there are three characteristics that I want to add to the legend: 1) The bars with color dark blue, 2) The bars with color light blue and 3) The vertical line. Does anyone

Manipulating legend text in R plotly

守給你的承諾、 提交于 2020-02-01 19:02:07
问题 I have a data.frame I'd like to scatter plot using R 's plotly with two factors which I'd like to color and shape by. Here's my data: set.seed(1) df <- data.frame(x=rnorm(12),y=rnorm(12), group=c(rep(1,3),rep(2,3),rep(3,3),rep(4,3)), treatment=c(rep("A",6),rep("B",6)), stringsAsFactors=F) df$group <- factor(df$group,levels=1:4) df$treatment <- factor(df$treatment,levels=c("A","B")) Here's how I'm trying to plot: require(plotly) plot_ly(marker=list(size=10),type='scatter',mode="markers",x=~df

Matplotlib scatter plot different colors in legend and plot

ε祈祈猫儿з 提交于 2020-01-30 02:48:29
问题 I have a scatter plot of multiple y-values for the same x-value, in matplotlib (python 2.7). There are different colors for all the plotted y-values. See the plot below. Now, here is the code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import pylab as pl import matplotlib.cm as cm # Generate test x, y and y_error values: df2a = pd.DataFrame(np.random.rand(10,5), columns = list('ABCDE')) df2a.insert(0,'x_var_plot',range(1,df2a.shape[0]+1)) df2a_err = pd.DataFrame(np

Writing 2 variables in a legend with 2 different plots

佐手、 提交于 2020-01-25 13:16:44
问题 I want to write 2 variables in my legend. legend('raw', 'suggested-signal: %f , suggested-filter: %f',a,b); I know this is wrong, but I don't know how else to include 2 variable in the legend. I have a way for 1 variable but not two. 回答1: If I get your intention correctly, you miss the sprintf : legend('raw', sprintf('suggested-signal: %f, suggested-filter: %f',x,y)); 回答2: I would dome something like this: legend('raw', ['suggested-signal: ' num2str(a)]', ['suggested-filter: ' num2str(b)]);

Horizontally align bar plot legends in python

本秂侑毒 提交于 2020-01-22 19:30:48
问题 I have made a multi axis graph using the following code and I am unable to arrange the legend as I want. The code of my graph is as follows: import matplotlib.pyplot as plt import numpy as np x = np.arange(4) y = [5, 7, 4, 9] z = [9, 3, 5, 6] r = [30, 40, 45, 37] fig,ax = plt.subplots() abc = ax.bar(x,y,0.25 ) cde = ax.bar(x+0.25,z,0.25) ax.legend((abc[0], cde[0]), ('y', 'z'),bbox_to_anchor=(0., 1.02, 1, .102) , borderaxespad=0.) ax.set_xticks(x + 0.25 / 2) ax.set_xticklabels(('A', 'B', 'C',