people! I defined a function that makes a graph from matplotlib similar to this one taken from How to write a function for barchart in python?:
def df_bar(df, xcol, ycol, xlabel=None, ylabel=None, title=None):
if xlabel is None:
xlabel = xcol
if ylabel is None:
ylabel = xcol
ax = textranges_freq.plot(x=xcol,y=ycol,kind='bar',title=title, width=0.5, legend=False)
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
plt.show()
My question is how to plot that into a matplotlib subplots funtion, what I mean is that, I want that graph appears two times side by side each, how do I make this?
I tried to define fig, axs and then using slicing "axs[0]" to plot, but didn't work, not even using subplots on matplotlib figure:
"ax1 = plt.subplot(1, 3, 1)
df_bar()
plt.title('bedrooms')"
fig, (ax1,ax2,ax3) = plt.subplots(1, 3)2. add anax=Noneparam to your function 3. add theaxto your plot command liketextranges_freq.plot(..., ax=ax)4. calldf_bar(..., ax=ax1)and so onplt.subplotsending ins