Python Forum
Plot a graph using matplotlib.pyplot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plot a graph using matplotlib.pyplot
#1
Hello I'm just starting to programme in Python :)

So I want to plot a graph using matplotlib.

my qustion is how to write a code which starts from the second line of data of a specific line

for example my plot is starts from 1962 but I want it starts from 1963.

how i do to make it works?
[Image: Y6rLeDW.jpg]

Thank you for any advice,
import matplotlib.pyplot as plt


plt.stackplot(time, DDI*100, SDI*100,CDI*100,WDI*100, colors=['green','red','yellow','blue'])  
plt.title('Drive mechanism')
plt.xlabel('Year')
plt.ylabel('Drive %')

plt.xticks(np.arange(min(time)+1, max(time), 5))
plt.show()
Reply
#2
Hi, thanks to Julián Urrea from facebook

but in the second term time[50] of the code how I know the last number of my list, maybe i have 200 lines?

plt.xlim([time[2],time[50]])

Hi

I found the solution ;)

plt.xlim([time[2],max(time)])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Embed Matplotlib Graph to Tkinter? dimidgen 0 229 Mar-04-2024, 07:40 PM
Last Post: dimidgen
  first time use plot - I get empty graph korenron 6 2,074 Feb-04-2023, 02:14 PM
Last Post: deanhystad
  Graphic line plot with matplotlib, text file in pytho khadija 2 1,375 Aug-15-2022, 12:00 PM
Last Post: khadija
  Is Matplotlib.pyplot Loaded DaveG 2 1,313 Apr-06-2022, 06:12 AM
Last Post: DaveG
  How to conditionally specify markers in matplotlib graph Mark17 3 3,213 Mar-03-2022, 07:42 PM
Last Post: Mark17
  Python 3.10 not happy with Pandas and PyPlot? Danno 1 1,569 Feb-26-2022, 05:35 AM
Last Post: Danno
  plot on the same figure using a for loo with matplotlib drSlump 2 1,707 Oct-13-2021, 07:11 AM
Last Post: drSlump
  matplotlib, no plot when using Figure ajvperth 2 1,677 Oct-12-2021, 02:29 PM
Last Post: ajvperth
  Unable to plot the graph as needed drunkenneo 1 6,345 May-26-2021, 11:04 AM
Last Post: cygnus_X1
  blank graph with matplotlib from a csv file / data type issue arsentievalex 0 1,947 Apr-06-2021, 10:08 AM
Last Post: arsentievalex

Forum Jump:

User Panel Messages

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