matplotlib

How to make an axes occupy multiple subplots when using pandas datetime plot?

感情迁移 提交于 2021-02-10 16:01:19
问题 I would like to create a (sub)plot with two rows and two columns where the plot in the lower row occupies both axes. Since I use the plot from within pandas datetime (I think) I was not able to use this solution. fig, axes = plt.subplots(nrows=2, ncols=2) df1.set_index('Date').plot(ax=axes[0,0]) df2.set_index('Date').plot(ax=axes[0,1]) df3.set_index('Date').plot(ax=axes ??? ) How do I need to assign the axes (if at all possible) in order to get something like this: 回答1: You can do in this way

How to make an axes occupy multiple subplots when using pandas datetime plot?

北慕城南 提交于 2021-02-10 16:00:22
问题 I would like to create a (sub)plot with two rows and two columns where the plot in the lower row occupies both axes. Since I use the plot from within pandas datetime (I think) I was not able to use this solution. fig, axes = plt.subplots(nrows=2, ncols=2) df1.set_index('Date').plot(ax=axes[0,0]) df2.set_index('Date').plot(ax=axes[0,1]) df3.set_index('Date').plot(ax=axes ??? ) How do I need to assign the axes (if at all possible) in order to get something like this: 回答1: You can do in this way

How to propagate `\n` to sympy.latex()

僤鯓⒐⒋嵵緔 提交于 2021-02-10 15:59:52
问题 The Goal is to format a polynomial with more than 6 parameters into a plot title. Here is my polynomial parameter to string expression function, inspired by this answer, followed by sym.latex() : def func(p_list): str_expr = "" for i in range(len(p_list)-1,-1,-1): if (i%2 == 0 and i !=len(p_list)): str_expr =str_expr + " \n " if p_list[i]>0: sign = " +" else: sign = "" if i > 1: str_expr = str_expr+" + %s*x**%s"%(p_list[i],i) if i == 1: str_expr = str_expr+" + %s*x"%(p_list[i]) if i == 0: str

closing of matplotlib.pyplot closes parent window also

╄→гoц情女王★ 提交于 2021-02-10 15:14:08
问题 I am a beginner with matplotlib. I am trying to generate bar chart on click of a button, which is working as expected. The problem is, I dont want the parent window i.e the window with "Hello World" button to be closed when I close the pyplot i.e bar chart window. I want only the pyplot to be closed when I click "x" on it. import pygtk pygtk.require('2.0') import gtk import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt class HelloWorld: def _

closing of matplotlib.pyplot closes parent window also

南笙酒味 提交于 2021-02-10 15:06:48
问题 I am a beginner with matplotlib. I am trying to generate bar chart on click of a button, which is working as expected. The problem is, I dont want the parent window i.e the window with "Hello World" button to be closed when I close the pyplot i.e bar chart window. I want only the pyplot to be closed when I click "x" on it. import pygtk pygtk.require('2.0') import gtk import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt class HelloWorld: def _

closing of matplotlib.pyplot closes parent window also

亡梦爱人 提交于 2021-02-10 15:06:23
问题 I am a beginner with matplotlib. I am trying to generate bar chart on click of a button, which is working as expected. The problem is, I dont want the parent window i.e the window with "Hello World" button to be closed when I close the pyplot i.e bar chart window. I want only the pyplot to be closed when I click "x" on it. import pygtk pygtk.require('2.0') import gtk import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt class HelloWorld: def _

Align twinx with second axis with non linear scale

断了今生、忘了曾经 提交于 2021-02-10 15:03:30
问题 I'm facing some problems in the alignment of the ticks of two different y-axes with the first characterized by a linear range and the second by a non linear range as depicted in the following picture. HS, TMN = np.meshgrid(hs, period) r = function(HS, TMN) cax = plt.contourf(HS, TMN, np.log10(HS), cmap=plt.cm.RdYlGn_r) ax = plt.gca() ax2 = ax.twinx() ticks2 = get_y2values(ax.get_yticks()) # Non linear function ax2.yaxis.set_major_locator(mpl.ticker.FixedLocator(ticks)) ax2.set_ylim([0, 700])

Align twinx with second axis with non linear scale

邮差的信 提交于 2021-02-10 15:00:59
问题 I'm facing some problems in the alignment of the ticks of two different y-axes with the first characterized by a linear range and the second by a non linear range as depicted in the following picture. HS, TMN = np.meshgrid(hs, period) r = function(HS, TMN) cax = plt.contourf(HS, TMN, np.log10(HS), cmap=plt.cm.RdYlGn_r) ax = plt.gca() ax2 = ax.twinx() ticks2 = get_y2values(ax.get_yticks()) # Non linear function ax2.yaxis.set_major_locator(mpl.ticker.FixedLocator(ticks)) ax2.set_ylim([0, 700])

create seaborn plot with pandas of matplotlib

本小妞迷上赌 提交于 2021-02-10 14:35:53
问题 I'm struggling to (re)create a seaborn plot with pandas or matplotlib. DataFrame: wage = pd.melt(pd.read_html('https://en.wikipedia.org/wiki/List_of_countries_by_average_wage')[8].iloc[:5], id_vars=['Country'],var_name='Year', value_name='Wage') print(wage.sample(n=7)) Result: Country Year Wage 29 Netherlands 2013 52808 38 United States 2015 60692 4 Netherlands 2000 47596 9 Netherlands 2005 49939 23 United States 2012 58669 46 Switzerland 2017 62283 12 Iceland 2010 44558 The plot using

Plotting phase portraits in Python using polar coordinates

末鹿安然 提交于 2021-02-10 14:26:48
问题 I need a phase portrait of the following nonlinear system given in polar form... \dot{r} = 0.5*(r - r^3) \dot{\theta} = 1 I know how to do it in Mathematica... field1 = {0.5*(r - r^3), 1}; p1 = StreamPlot[Evaluate@TransformedField["Polar" -> "Cartesian", field1, {r, \[Theta]} -> {x, y}], {x, -3, 3}, {y, -3, 3}, Axes -> True, StreamStyle -> Gray, ImageSize -> Large]; Show[p1, AxesLabel->{x,y}, ImageSize -> Large] How can I do the same using pyplot.quiver in Python? 回答1: Just very naive