legend

Matplotlib: Remove line “dashes” and only display text in legend

空扰寡人 提交于 2019-12-23 01:46:05
问题 Created a legend and formatted the text as needed, but can't figure out how to remove the line "dashes" so that only text appears. Here's what I'm getting now (notice how the line is going through the text that is being right aligned): #Add legend leg = ax1.legend(bbox_to_anchor=(0.03, 1.05), prop={'size':8}) leg.get_frame().set_alpha(0) legText = pylab.gca().get_legend().get_texts() #Format legend text legText[0].set_color('#5998ff') legText[1].set_color('#ffbb82') legText[2].set_color('

One legend for all subplots in pyplot

假装没事ソ 提交于 2019-12-23 01:12:55
问题 I am currently plotting the same data but visualizing it differently in two subplots (see figure): Code snippet used for producing the above figure: # Figure plt.figure(figsize=(14,8), dpi=72) plt.gcf().suptitle(r'Difference between TI and $\lambda$D', size=16) # Subplot 1 ax1 = plt.subplot2grid((1,3),(0,0),colspan=2) # Plot scattered data in first subplot plt.scatter(LE_x, LE_y, s=40, lw=0, color='gold', marker='o', label=r'$\lambda$D') plt.scatter(MD_x, MD_y, s=40, lw=0, color='blue',

Two adjacent symbols in matplotlib legend

纵然是瞬间 提交于 2019-12-22 10:57:07
问题 I would like to identify two different symbols (with different colors) on the same line in a legend. Below, I tried doing this with Proxy Artists, but the result is that they get stacked on top of each other in the legend. I want them next to each other or one above the other-- so they are both visible. from pylab import * import matplotlib.lines as mlines #define two colors, one for 'r' data, one for 'a' data rcolor=[69./255 , 115./255, 50.8/255 ] acolor=[202./255, 115./255, 50.8/255 ] #Plot

Customizing the order of legends in plotly

妖精的绣舞 提交于 2019-12-22 09:57:43
问题 I am trying to customize the order of legends while plotting stacked bar plots in plotly,python. data = [ go.Bar( y=df['sid'], # assign x as the dataframe column 'x' x=df['A'], orientation='h', name='A' ), go.Bar( y=df['sid'], x=df['B'], orientation='h', name='B' ), ] layout = go.Layout( barmode='stack', title=f'{measurement}', xaxis=dict( title='Count', dtick=0), yaxis=dict( tickfont=dict( size=10, ), dtick=1) ) fig = go.Figure(data=data, layout=layout) plot(fig, filename='plot.html') The

Why does Firefox 4 absolutely position fieldset legends differently than other browsers?

寵の児 提交于 2019-12-22 09:49:28
问题 Why does Firefox 4 absolutely position fieldset legends differently than other browsers? Test page: <!DOCTYPE html> <html dir="ltr" lang="en"> <head> <meta charset="utf-8"/> <title>Test</title> <style type="text/css"> * { margin: 0; padding: 0; } body { font-family: Tahoma, Arial, sans-serif; font-size: 62.5%; } #wrapper { margin: auto; padding: 1em; width: 720px; } form { width: 670px; padding: 25px; background-color: #ffffff; /* White */ color: #000000; /* Black */ border: 1px solid #cccccc

AmChart legend in one line

只愿长相守 提交于 2019-12-22 09:26:14
问题 I'm trying to get AmChart chart legends into one line, but without luck. Legends are separated (one for line). Actual settings for from documentation http://docs.amcharts.com/3/javascriptcharts/AmLegend is following. "legend": { "equalWidths": false, //"periodValueText": "total: [[value.sum]]", "position": "bottom", "valueAlign": "left", "labelWidth": 100, "valueWidth": 200, //"width": 100, "align": "center" }, I Would like to ask how to get all chart legends into one line? Many Thanks for

Remove white space (i.e., margins) ggplot2 in R

℡╲_俬逩灬. 提交于 2019-12-22 08:05:58
问题 I'm trying to plot a pie chart using GGPLOT2 in R. I want to do this in such a way as to omit the extra margin space. What I'm doing is similar to what sharoz did in this post here except I want to include a legend. Here is what I'm doing: ggplot(DATA, aes(x=factor(0),fill=factor(LABELS),weight=VALUES)) + geom_bar(width=1) + coord_polar(theta='y') + guides(fill=guide_legend(title='LEGEND')) 回答1: Assuming you are talking about the extra white space above and below the figure, the easiest

R plotly version 4.5.2 scatterplot legend bubble size settings

南楼画角 提交于 2019-12-22 06:49:58
问题 I am using plotly 4.5.2 in R. I have created a scatterplot which is sized on a variable, the issue is these sizes are also reflected in the legend which makes them hard to read. I want my graph to remain the same, with the only exception being the size of the bubbles in the legend. These bubbles can either be set to all be the same size or scaled to a smaller size. Importantly, the sizes in the graph must remain the same. Please find reproducible code here: library(plotly) data <- data.frame

Manually creating a legend when you can't supply a color aesthetic

一世执手 提交于 2019-12-22 06:40:43
问题 In attempting to answer this question, one way to create the desired plot was to use geom_dotplot from ggplot2 as follows: library(ggplot2) library(reshape2) CTscores <- read.csv(text="initials,total,interest,slides,presentation CU,1.6,1.7,1.5,1.6 DS,1.6,1.7,1.5,1.7 VA,1.7,1.5,1.5,2.1 MB,2.3,2.0,2.1,2.9 HS,1.2,1.3,1.4,1.0 LS,1.8,1.8,1.5,2.0") CTscores.m = melt(CTscores, id.var="initials") ggplot(CTscores.m, aes(x=variable, y=value)) + geom_dotplot(binaxis="y", stackdir="up",binwidth=0.03) +

Adding legend to a single line chart using ggplot

☆樱花仙子☆ 提交于 2019-12-22 06:39:35
问题 I just try to make a line chart and add a legend to it using ggplot in R. The following is my code. ggplot(mtcars, aes(x=mpg, y=wt)) + geom_line(stat = "identity") + scale_fill_identity(name = "", guide = "legend", labels = c("myLegend")) and I got the following: The legend is not shown in the plot and what I want is the following: which I plot using Matlab. Could anyone tell me how to do it in R? Thank you so much!! 回答1: You plot is not showing a legend, because there are no aesthetics