Issue
The below set of code previously worked well and I was able to visualise the boxplot graph well. This code was previously used in another project of mine, and it worked perfectly well. There were no changes done to this piece of code, and it is being reused here.
I have a 'df' dataframe and I am trying to create boxplots to visualise outliers. Unfortunately, the graph doesn't seem to visualise anything. I am not sure what is wrong with my set of code. Could someone please help?
df = pd.DataFrame({'TotalPrice':[1.000, 0.650, 0.0075, 0.0025, 0.200],
'Voltage':[13.47, 13.41, 13.41, 13.41, 13.41],
'ConversionFactor':[934.0, 934.0, 2580.0, 934.0, 934.0],
'Litres':[40.0, 26.0, 3.0, 1.0, 8.0]})
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
import warnings
warnings.filterwarnings("ignore")
%matplotlib inline
%pylab inline
df = pd.read_csv('dataset.csv')
fig, ax = plt.subplots(1,4, figsize = (8, 4))
ax[0].boxplot(df.TotalPrice)
ax[1].boxplot(df.Voltage)
ax[2].boxplot(df.ConversionFactor)
ax[3].boxplot(df.Litres);
Solution
If you change from inline
to notebook
, and remove your pylab reference, it will work as expected within Jupyter Notebook:
%matplotlib notebook #< not inline
# %pylab inline #< this is not needed
Answered By - pfabri
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.