matplotlib

Custom scientific axis unit for a bar plot with log scale x-axis

孤街醉人 提交于 2021-02-10 07:23:19
问题 Let's consider the following example to plot some y values for given x values. import matplotlib.pyplot as pyplot if __name__ == "__main__": x = [1000000000, 2000000000, 4000000000, 8000000000] y = [0.342, 0.543, 0.874, 1.324] pyplot.bar(x, y) pyplot.savefig("test1.png", format="png") pyplot.close() pyplot.bar([str(int(x_value / 1000000000)) for x_value in x], y) pyplot.savefig("test2.png", format="png") pyplot.close() My goal is to have equally-spaced x-ticks for all x values (i.e., not

Multiple size font in suptitle

ぃ、小莉子 提交于 2021-02-10 07:07:45
问题 I would like to have multiple title in my graph. A picture is better than anyword : I use a title for every graph (D2/E, D3/E and D4/E) and a suptitle for title 1 and 2 but they have the same font size. Is there a solution to have different size for Title 1 and Title 2 ? I've already seen this solution using LaTeX but the thing is when I use plt.rc('text', usetex=True) every font and text are changed. Moreover, I use variable in each title and it looks like I can't do it with LaTeX. 回答1: You

Multiple size font in suptitle

泄露秘密 提交于 2021-02-10 07:06:02
问题 I would like to have multiple title in my graph. A picture is better than anyword : I use a title for every graph (D2/E, D3/E and D4/E) and a suptitle for title 1 and 2 but they have the same font size. Is there a solution to have different size for Title 1 and Title 2 ? I've already seen this solution using LaTeX but the thing is when I use plt.rc('text', usetex=True) every font and text are changed. Moreover, I use variable in each title and it looks like I can't do it with LaTeX. 回答1: You

Multiple size font in suptitle

霸气de小男生 提交于 2021-02-10 07:05:19
问题 I would like to have multiple title in my graph. A picture is better than anyword : I use a title for every graph (D2/E, D3/E and D4/E) and a suptitle for title 1 and 2 but they have the same font size. Is there a solution to have different size for Title 1 and Title 2 ? I've already seen this solution using LaTeX but the thing is when I use plt.rc('text', usetex=True) every font and text are changed. Moreover, I use variable in each title and it looks like I can't do it with LaTeX. 回答1: You

how to plot a dataframe grouped by two columns in matplotlib and pandas

梦想的初衷 提交于 2021-02-10 06:52:30
问题 I have the following dataframe: total_gross_profit first_day_week var Feb-06 1 45293.09 2 61949.54 Feb-13 1 44634.72 2 34584.15 Feb-20 1 43796.89 2 37308.57 Feb-27 1 44136.21 2 38237.67 Jan-16 1 74695.91 2 75702.02 Jan-23 1 86101.05 2 69518.39 Jan-30 1 65913.56 2 74823.94 Mar-06 1 34256.47 2 31953.00 grouped by first_day_week and var columns i need to make a bar plot where i have first_day_week in x axis and for each entry in first_day_week two bar plot for each value in var in different

how to plot a dataframe grouped by two columns in matplotlib and pandas

感情迁移 提交于 2021-02-10 06:52:12
问题 I have the following dataframe: total_gross_profit first_day_week var Feb-06 1 45293.09 2 61949.54 Feb-13 1 44634.72 2 34584.15 Feb-20 1 43796.89 2 37308.57 Feb-27 1 44136.21 2 38237.67 Jan-16 1 74695.91 2 75702.02 Jan-23 1 86101.05 2 69518.39 Jan-30 1 65913.56 2 74823.94 Mar-06 1 34256.47 2 31953.00 grouped by first_day_week and var columns i need to make a bar plot where i have first_day_week in x axis and for each entry in first_day_week two bar plot for each value in var in different

Multi-lines(with different markers) in legend

五迷三道 提交于 2021-02-10 06:30:09
问题 I want to show multi-lines with the same label but different markers in legend. The graph I want to plot is similar to this: But there's no marker setting in LineCollection , I expect each line has different marker. Any idea? Thank you. 回答1: The picture you show stems from the legend demo. Similar to what is done there you may subclass a legend handler to create a legend of choice. Here one may use a HandlerTuple such that one can directly supply the complete list of lines in the legend.

How to plot only the lower triangle of a seaborn heatmap?

眉间皱痕 提交于 2021-02-10 06:16:06
问题 I've a list of lists all_genres where each sub-lists contain genres for a particular tv-show and each different sub-list refers to different tv-shows. I want to plot a seaborn heatmap but with only the lower traiangle part. Here is what I've tried so far : import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set(rc={'figure.figsize':(16,9)}) all_genres = [['Drama', 'History'], ['Documentary'], ['Action', 'Drama', 'History'], ['Documentary'], ['Crime', 'Drama',

Plot a time series grouped by id

 ̄綄美尐妖づ 提交于 2021-02-10 06:15:18
问题 I want to plot a time series grouped by id. So that time is my x-value and 'value' is my y-value. How can I plot x and y grouped by 'id' 1? id time value 1 1 0.3 1 2 0.6 1 3 0.9 2 1 0.1 2 2 0.3 2 3 0.6 3 1 0.2 3 2 0.4 3 3 0.5 回答1: I think you can use pivot with DataFrame.plot.bar or only DataFrame.plot: import matplotlib.pyplot as plt df = df.pivot(index='time', columns='id', values='value') print (df) id 1 2 3 time 1 0.3 0.1 0.2 2 0.6 0.3 0.4 3 0.9 0.6 0.5 df.plot.bar() plt.show() df = df

Setting the interval of x-axis for seaborn plot

一曲冷凌霜 提交于 2021-02-10 04:21:16
问题 I have a set of subplots to plot. Here, how do we set the interval for x-axis in the subplot in second row, i.e ax4 to ax6 . Currently all the values from 1 to 100 are printed as shown in the figure. I tried ax4.set_xticks(range(1,100,5)) . But there, the range shown was 1 to 20. I was expecting a range from 1 to 100, with an interval of 5, i.e. 1,5,10...95,100 Currently the plot has x-axis as shown below. I have not added the code for first row. yInit = initRes yInit = yInit[(yInit['nodeSKT'