Python Forum
Subplot - Plotting 4 plots on the same row
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subplot - Plotting 4 plots on the same row
#1
Hello !
I'd like to plot 4 plots on the same raw but I don't know how... I tried the command : plt.subplot(1,4,) but it doesn't seem to work.

You'll find the notebook on my GitHub (https://github.com/MathisGitHub/La-Comed...-1733-1734) and the code is at entry 78. The code looks like :
actes=[1.0, 2.0, 3.0, 5.0]

plt.figure(1,figsize = (20, 20))
plt.suptitle('Nombre utilisateurs pour chaque jour de la semaine')

for i in actes :
    plt.subplot(4,4,i, title="Nature du texte pour une pièce en " + str(int(i)) + ' acte(s)')
    plt.ylim(ymax=250)
    CF_saison[(CF_saison['acts_x'] == i)]['prose_vers'].value_counts().plot(kind='bar')
Thank you very much for your help ! Smile Smile
Reply
#2
You must have use subplot incorrectly. Here's four plots in a row.
import matplotlib.pyplot as plt

actes=[1.0, 2.0, 3.0, 5.0]
fig, ax = plt.subplots(1, 4)
for a in ax:
    a.plot(actes)
plt.show()
https://matplotlib.org/stable/gallery/subplots_axes_and_figures/subplots_demo.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cannot remove one of the x-ticks from a 2x1 subplot. generalzu10 1 252 Mar-20-2024, 04:24 AM
Last Post: generalzu10
  Multiple Plots in Spyder PythonAndMe2023 0 871 Feb-03-2023, 07:00 PM
Last Post: PythonAndMe2023
  How to preserve x-axis labels despite deleted subplot? Mark17 1 1,922 Dec-23-2020, 09:02 PM
Last Post: Mark17
  create loop of subplot plotly dash without hardcode tonycat 0 3,909 Sep-23-2020, 08:40 AM
Last Post: tonycat
  Sharing X Axis in Sub plots JoeDainton123 1 2,180 Aug-22-2020, 04:11 AM
Last Post: deanhystad
  Help With Sub Plots JoeDainton123 0 1,699 Aug-20-2020, 10:48 PM
Last Post: JoeDainton123
  Group scatter plots Mekala 0 1,645 Jul-23-2020, 02:18 PM
Last Post: Mekala
  Saving multiple plots as pdf mohd_umair 0 3,339 Apr-28-2019, 01:21 PM
Last Post: mohd_umair
  Can't locate plots package BobLoblaw 12 10,932 Oct-04-2017, 11:56 PM
Last Post: BobLoblaw
  Adding text to plots shaynehansen 0 3,322 Jul-10-2017, 05:54 PM
Last Post: shaynehansen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020