I want to call a function from a class in which I want to plot several figures. There is no error thrown but I did not receive the plot but only:
#############################################
Histograms of the continuous data:
#############################################
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
The code I use is:
class Pipeline:
import matplotlib.pyplot as plt
global plt
from matplotlib import style
style.use('ggplot')
def __init__(self,goal):
self.goal = goal
def examine(self,dataset):
# Check for categorical and continous data
continuous = []
categorical = []
for n,i in enumerate(dataset.columns):
if isinstance(dataset[i][1],str):
categorical.append(dataset.columns[n])
else:
continuous.append(dataset.columns[n])
continuous_data = dataset[continuous]
categorical_data = dataset[categorical]
#Plot the histograms of the continuous data
print('#############################################')
print('Histograms of the continuous data:')
print('#############################################')
for col in continuous_data.columns:
fig = plt.figure()
ax = continuous_data[col].hist()
ax.set_title(col)
plt.show()
pipe = Pipeline('C')
pipe.examine(data)
I wonder because if I run the same code a second time it plots the figures just as proposed. Appreciate any help!
It looks like you are using Jupyter. To have plots show in Jupyter you can add either
%matplotlib inline
or
%matplotlib notebook
(for a slightly more fancy plotting option)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With