There are two txt files. You need to open them and build graphics. For the first case, you need to build a graph for the numbers of positive and negative - separately. For the second file - the graph ... in it, and so all the numbers are positive). Well, save the graphics)

55 -316 148 -126 109 -168 41 -333 85 -123 70 -11 35 -97 190 -104 42 -136 144 -22 194 -64 23 -669 

and

 5 29 31 10 12 33 5 45 18 17 14 
  • which graph is linear, "bars", "pie", something else? - MaxU
  • let it be linear) - Jon S.
  • для чисел положительных и отрицательных - по отдельности - are these two lines on the graph or two graphs? - MaxU

1 answer 1

 import pandas as pd import matplotlib.pyplot as plt import matplotlib matplotlib.style.use('ggplot') # здесь читаем данные в DataFrame: # пример: http://ru.stackoverflow.com/a/630264/211923 ax = df[df['col'] > 0].plot(figsize=(14,10)) df[df['col'] < 0].plot(ax=ax) plt.show() ax.get_figure().savefig('c:/temp/picture.png') 

Result:

enter image description here

bar graph (use seaborn module):

 import seaborn as sns ax = sns.barplot(data=df.assign(sign=np.where(df.col >= 0, 'positive', 'negative')), x=df.index, y='col', hue='sign') ax.get_figure().savefig('c:/temp/pic2.png') 

Result: enter image description here

  • Everything works except save graphs. Saves to white a clean file, although the graphics are output - Jon S.
  • And by the way, is building a bar graph instead of a linear graph much more difficult? or does one line change? - Jon S.
  • @JonS., By the way, what do these numbers mean? Knowing more details you can give more practical advice (sometimes) ... - MaxU
  • The sensor measures the level of pressure in the tank during a chemical reaction :) - Jon S.
  • and where is the timeline? Or is there a constant measurement interval? - MaxU