Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 how to include characters in a diagram with matplotlib
I created an application with which if I click on the button "save", there is creation of a text file in which I save data in columns. among these data there is the date in first colone
here is the contents of the file (file.txt):

01/12/2010 ... 0.132
02/05/2011 ... 0.186
28/12/2011 ... 0.168
04/06/2012 ... 0.122
29/12/2012 ... 0.144
06/06/2013 ... 0.112
07/01/2014 ... 0.186
08/06/2014 ... 0.168
19/12/2014 ... 0.152
10/06/2015 ... 0.164

this content is not fixed since each time you click on the save button a new line is added to the text file

import numpy as np
import matplotlib.pyplot as plt

def graphe_loc35R():
	x,y = np.loadtxt("file.txt", unpack=True)

I would like help to find out how to include characters in the x-axis of a diagram built with matpltlib

Quote:I would like help to find out how to include characters in the x-axis of a diagram built with matpltlib
So you want the date labels on the X-axis?
If so you are going to want the xticks function.
Something like:
plt.xticks(x_values, labels, rotation=30)
but this code is for limited number of values. at my text file (file.txt), the number of line is not fixed and il will be modify each time a personn click on save button
It can absolutely work. Load the dates into a variable named labels anytime it changes and update your xticks.
I did not understand your answer
I would like you to facilitate me the task by procuring me the procedure if it is possible, since I am still a beginner with regard to the programming and especially the python language
thank you

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Should you include uneven data donnertrud 0 160 Jan-20-2020, 07:42 AM
Last Post: donnertrud
  error: INCLUDE environment variable is empty xwchen 4 4,049 Mar-22-2018, 03:40 AM
Last Post: xwchen

Forum Jump:

Users browsing this thread: 1 Guest(s)