Scatter Plot of a Specific Column in Python using matplotlib - python

I am very new to Python, but I am determined to learn how to use it. At the moment, I am working with .dat files that have a few columns only separated by spaces.
I was wondering if there is anyway that I can make a scatter plot with a specific column accompanied by each value's non-negative integer? (i.e. 0,1,2,3,4...).
Here is an example of the data I am working with:
Here is an example graph of what I would want to be the end result:

Related

Full datetimes in x-axis

I am new to programming in general, and I have started with Python. I have a project where i have to create various plots (y-axis: voltage, frequency etc, x-axis: exact datetimes ) from a csv file which contains the meterings of a home smart meter. I try to create a plot between 2 certain datetimes (not from start to end). I have fairly managed to do it but I face some problems in concern of the x-axis. I want to get for example "2020-09-22 09:00:02" but I get for example "9-22 10".
enter image description here

convert one Matplotlib graph into two when there are two many categorical values

I have the recurrent issue of having matplotlib bar graphs containing too many categorical values in the X axis. Resize a figure automatically in matplotlib and Python matplotlib multiple bars does not make the trick because my x values are not x. I am having the idea of splitting the graph into two graphs when it get past a certain amount of data point in the graph. I cannot find anything about in the matplotlib document, nor anywhere.
Is there a matplotlib tool to do that? or i would need to write an algorithm that detects the length of the dataset?

How to plot multiple CSV files as a boxplot on the same plot

I have 13 different saved CSV files in a folder and each file contains just one column of data (i previously saved these separately from a larger dataset using python having calculated what I needed to), I would like to plot each of these files as 13 different boxplots on the same plot.
I am quite new to python and I'm familiar with matplotlib, so far I know how to plot each of these files individually but of course, I would like them to be plotted next to each other so I can better compare and visualise my data.
here are two of my plots:
usingplt.boxplot(af,meanline=True,showmeans=True)
boxplot1
boxplot2
this is how I named/saved my files (just 2 of them here)
af=numpy.loadtxt(fname='af_river.csv.')
am=numpy.loadtxt(fname='am_river.csv.')
but I don't know where to go from here, do I/is there a way to create a loop which goes through each of these files separately and plots them next to each other?
Try this
plt.boxplot([af,am],meanline=True,showmeans=True)
This will plot all the files in the same plot

generate heat map of large array from csv using python

I have a data set that has a somewhat strange layout of the data itself. it looks like this:
It's actually in csv format but I showed it above in excel for convenience.
so the x-axis values are located in the first column. The y-axis values are in the first row. Each blue cell is a data point, with the value in the cell representing an intensity. So the for the top left cell, the coordinates would be [0.000146,0,0]. The one below would be [0.000478,0,114]. I'm trying to figure out how to actually get this data plotted like a 2-D heatmap where the intensity is represented by the color, but haven't been able to do so so far. Any suggestions for how to go about doing this? I've looked at some matplotlib and pandas tutorials but they don't seem to address data formatted this way.

Python - Matplotlib - Plotting incomplete data on chart

I am trying to write program to generate burndown chart. The x-axis is of dates. The y-axis shows remaining hours on a particular date. The problem is that data is not present for all the dates in advance as it is a burndown chart. So this results in error -
"ValueError: x and y must have same first dimension"
So my question is what default values I can assign to the remaining points on Y-axis?
I will paste actual code if this information is not sufficient. Thanks.
I'm not sure if this is what you want, but by using masked arrays you can avoid plotting specific points. See my answer here.
Or maybe you'd like something more like this, which skips them on the x-axis as well as not plotting them?
I know this question is 2 1/2 years old, but I had a similar problem with plotting graphs with missing data and thought that masked arrays were more complex than they needed to be.
My solution was to put the numpy.inf value at any points where I was missing data and then use the 'o-' option when calling matplotlib.pyplot.plot. This will make lines be broken where you don't have data, but if you have a single data point somewhere missing data on each side of it, you get a circle.
The only downside is that you end up with circles at every point on the line, so it might not be pretty.

Categories

Resources