# matplotlib graph to plot values and variance

I am really new to the world of matplotlib graphing as well as using those graphs to understand data.

I have written a simple python code where I read a .csv file in and then store the values of one column into a variable. Then plotting them similar to the code bellow:

dev_x= X   #storing the values of the column to dev_x
plt.plot(dev_x)
plt.title('Data')


The graph looks like this, which seems quite messy and hard to understand. So, I am asking for some advice on how to make more cohesive graphs.

This is what my .csv column looks like. It is just many other other rows.

['40' '20' '10' '0' '10' '30' '50' '70' '90' '110' '130' '150' '170' '200'
'240' '290' '40' '20' '10' '0' '10' '30' '50' '70' '90' '110' '130' '150'
'170' '200' '240' '290' '40' '20' '10' '0' '10' '30' '50' '70' '90' '110'



At the end of the day I would like a way to display these in a better way so I can also find the variance of this column.

You have currently stored your numbers as strings causing matplotlib to treat your variable as categorical, hence the y-axis is not ordered as expected. Before plotting you should therefore first convert them to integers like this:

x = [float(i.replace(",", ".")) for i in dev_x]


You can then use plt.plot(x) once again to plot the values, this should give you the following plot:

Edit:

Using the csv file you've provided, I am using the following code to read in the data and create the plot:

import matplotlib.pyplot as plt
import pandas as pd


• I have tried the following order x = [int(i) for i in dev_x] plt.plot(dev_x)  unfortunately I am getting the following error ValueError: invalid literal for int() with base 10: '23,43'  – E199504 Feb 1 '20 at 11:12
• thank you this is where I have included your line of code x = [float(i.replace(",", ".")) for i in dev_x] plt.plot(dev_x)  my graph is still looking the same . Here is a picture showing the results I am getting with your code and without Picture – E199504 Feb 1 '20 at 12:36