0

I am plotting 2 graphs in a single plot but Matplotlib is only showing the legend of only 1 graph.

Here's the code -

fig = plt.figure(figsize=(5,5), dpi = 100)
ax_left = fig.add_subplot()
ax_right = ax_left.twinx()

rho_graph = ax_left.plot(x[:],rho[:], label = 'rho', color = 'red',linewidth = 1.3)
mach_graph = ax_right.plot(x[:],mach_number[:],label = 'mach', color = 'blue',linewidth = 1.3)

ax_left.set_ylabel(r"Non Demensional density  $\frac{\rho}{\rho_o}$")
ax_right.set_ylabel('Mach Number')

plt.legend()

here's the result - Final graph. Only 1 legend is shown

So what should I add?

0 Answers0