0

For example, I calculated a table as in the image. And I want to get 12 charts in the same area (4*3) So the first row will be for X, and the second row will be for y, third row for z and forth row for z. The first column will be for the plot where I have fare ty (this year) shown together with fare diff (% difference) on the y axis and feature names as weeks on the x axis. The second column will be for the plot where I have revenue ty (this year) shown together with revenue diff (% difference) on the y axis and feature names as same weeks on the x axis. The third column will be for the plot where I have rev/mile diff (% difference) shown on the y axis and feature names as weeks on the x axis. Trying something like this, but it does not work:

fig, ((ax1, ax2, ax3), (axs4, axs5, ax6), (ax7, ax8,ax9) ,(ax10, ax11,ax12) ) = plt.subplots(nrows=4, ncols=3, sharex=True, sharey=True, figsize=(16, 10))

ax1 = plt.subplot2grid((4,3),(0, 0)) ax1.plot(df['x fare th'], df.columns.values, s=15)

ax2 = plt.subplot2grid((4,3),(0, 1)) ax2.bar(df['x rev th'], df.columns.values, s=15)

.....

ax12 = plt.subplot2grid((4,3),(3, 3)) ax12.plot(df['t rev/mile diff'], df.columns.values, s=15)

Can I use the df as it is to be able to get these plots? Do I have to convert my data frame into some other format to plot the charts? If, what is the necessary change for ddataframe?

Thank you in advance!

Current Data frame to be used for plotting

I tried something like this:

fig, ((ax1, ax2, ax3), (axs4, axs5, ax6), (ax7, ax8,ax9) ,(ax10, ax11,ax12) ) = plt.subplots(nrows=4, ncols=3, sharex=True, sharey=True, figsize=(16, 10))

ax1 = plt.subplot2grid((4,3),(0, 0)) ax1.scatter(df['x fare th'], df.columns.values, s=15)

ax2 = plt.subplot2grid((4,3),(0, 1)) ax2.scatter(df['x rev th'], df.columns.values, s=15)

.....

ax12 = plt.subplot2grid((4,3),(3, 3)) ax12.scatter(df['t rev/mile diff'], df.columns.values, s=15)

but it did not work.

And I want to see something like:

Just plotting 12 charts in the same area with weeks on the X axis

BT K
  • 1
  • 1

0 Answers0