0

I would like to get a grouped bar that shows both the positive and negative values in one graph. I found a similar question but they are getting the values from a list and not a dataframe. I'm new to using python for graphing so I'm not sure how to change it for a dataframe.

I am able to get something similar to that with my numbers if I make each one individually and then in powerpoint I put the negative number graph below the positive number graph. I feel like there is a better/correct way to do this.

Here is the code I used to get the individual plots

#positive number graph
Positive_CellExterior.plot(x='Pathway',
        kind='bar',
        stacked=False,
        color=['#C4122E','#003663'])

plt.setp(plt.gca(), ylim=(0, 100))

plt.savefig("up.jpg", bbox_inches='tight')

#negative number graph
Negative_CellExterior.plot(x='Pathway',
        kind='bar',
        stacked=False,
        color=['#C4122E','#003663'])

plt.setp(plt.gca(), ylim=(-100,0))
plt.savefig("down.jpg", bbox_inches='tight')

I apologize if this has been asked before. Thank you in advance!

Here are the values if it helps

Positive numbers:

Pathway WT 23 vs. WT 37 Sig WT 23 vs. WT 37 NS
Transport 9.84 12.97
Flagella 25.93 37.04
OMP 8.28 12.41

Negative numbers:

Pathway WT 23 vs. WT 37 Sig WT 23 vs. WT 37 NS
Transport -30.45 -14.67
Flagella -12.6 -13.68
OMP -6.7 -25.93
  • Could you at least add the code you want to use to create the individual plots? That would make it much easier to know what kind of grouping you want, and how it could be adapted to putting everything onto one graph. – JohanC Apr 12 '22 at 21:42
  • @JohanC That is a good point! Yes, I can totally add that. – Melissa Arroyo-Mendoza Apr 12 '22 at 21:51
  • So maybe `ax = Positive_CellExterior.plot(.........)` and then `Negative_CellExterior.plot(....., ax=ax)`. `ax.set_ylim(-100,100)` would then change the y limits. – JohanC Apr 12 '22 at 22:06

0 Answers0