2

I have been trying to plot a simple bar chart using Seaborn. Oddly enough the previous plots worked, but these ones do not appear. No error is being thrown and as far as I can tell the code is okay. Perhaps a more experienced eye will be able to find an error.

import pandas as pd
import numpy as np
import pyodbc 
import matplotlib.pyplot as plt
import seaborn as sns

region_pct_25 = region_totals.iloc[0:6, :]
region_pct_25['Opp_Lives_pct'] = ((region_pct_25.Lives / region_pct_25.Lives.sum())*100).round(2)
region_pct_25.reset_index(level=['RegionName'], inplace=True)
region_25_plt = sns.barplot(x="RegionName", y="Opp_Lives_pct", data=region_pct_25, color = 'g').set_title("Client Usage by Region: ADD ")
plt.show()

No plot is showing. Please help wherever you can!

zabop
  • 6,750
  • 3
  • 39
  • 84
  • 1
    If you are running inside a notebook, you might add [`%matplotlib inline`](https://stackoverflow.com/questions/43027980/purpose-of-matplotlib-inline) (or `%matplotlib notebook` if you need a more interactive plot). Anyhow, the problem is related to the environment where you're running it. – JohanC Jul 15 '20 at 17:38
  • im using spyder. it is odd that the other seaborn plots have been okay and it is only this one. – KeithRoberts Jul 15 '20 at 17:53

1 Answers1

2

adding %matplotlib inline to the preamble resolved the issue!

Dharman
  • 30,962
  • 25
  • 85
  • 135