How can I plot time-series on matplotlib polar plot? - python-3.x

Unsure if a polar plot is exactly what I should be using to accomplish this. But, essentially, I have multiple time-series (just amplitude vs. time), each corresponding to a different angle in degrees. For example, I have ampl. vs time at 5 degrees, 10 degrees, 15, etc. For angles 0 to 360 at increments of 5, I would like to plot each time series on a circular, or polar plot.
I am attempting to do this with matplotlib and the projection='polar' flag on. There are 8000 amplitude values for each time-series. They are in a numpy array called data. To test plotting the time-series associated with 5-degrees, I made a numpy array of 8000 5's with 5*np.ones(8000) so that they are the same length.
thetas=np.arange(0,365,5) #make 0 to 360 degrees at increments of 5
ax=plt.subplot(111,projection='polar') #turn on polar projection
ax.plot(5*np.ones(8000),data)
plt.show()
I get:
You can see these data are not plotting along the 5-degree line, nor does it look like any amplitudes are showing (there should be squiggles up and down varying with time). Thank you in advance!
EDIT: Example of what I want (each color line is a different time-series)

Related

How to interpolate axis labels in matplotlib imshow

I have a scientific 2D matrix that I want to plot. The bin labels are monotonically increasing real numbers which are are frequently on a logarithmic or another non-linear scale. As seen below, replacing the ticks and plotting the bin values directly for each bin is not really very pretty. What are my options?
I would prefer to only make ticks at integer values of each coordinate, even if that tick would not correspond to any particular bin but instead be somewhere in-between the bins.
Another request, if possible, is to then convert the labels to a logarithmic scale, namely, instead of [1,10,100,1000,10000] write 10^1, 10^2, 10^3, 10^4, 10^5.

Understanding Density Plots from Pandas DataFrames

I am trying to understand the distribution of my data for a particular column. It has close to ~1 Million records.
Here is the code that I have written to see the density plot.
df[ "ratio"].plot.kde(bw_method=0.1) # Plot continuous column
https://wellsr.com/python/python-pandas-density-plot-from-a-dataframe/
Here is the plot that I get:
I am not clear what does x-axis and y-axis indicate?
Is x-axis the ratio values from dataframe?
What does Density means in y-axis and how it is calculated?
Do we have any such formula to derive this values in y-axis? I am more interested in deriving the values. Given the column ratio how can we come up with density values. Can someone quickly show the maths?
If you are plotting a KDE, it means you are plotting a Probabilistic Density Function (PDF) of a random variable.
The X-Axis will be the range of values of the parameter you are plotting for. In your case, since you are plotting for Ratio, X-Axis will represent the range of values of your parameter ratio
Y-Axis on the other hand represents kernel density i.e the probability of the parameter your are plotting for.
Read the documentation

Gnuplot Plotting Multiple Interpolated Surfaces in One Image

I am trying to visualize results from varying three different parameters using gnuplot. I can produce a 4D plot by using an xyz scatter plot with color as the fourth dimension. Now what I want to do is to take the limited data I have and produce higher quality images. As seen below, if I angle the 4D plot in just the right way I can get what looks like a series of 3D plots along one dimension. Is there a way I can individually interpolate these 3D slices and obtain smoothed planar surfaces for the cross-sections instead of the scatter plot form I currently have?
4D Scatter Plot Angled to Look Like 3D Cross-Sections:
New in version 5.4 (please try and report on the release candidate!)
http://gnuplot.sourceforge.net/demo_5.4/voxel.html

Gnuplot: Polar plot showing variable ranges

I've got a dataset of angle ranges that I'd like to represent as a polar plot.
The format is as follows:
[Radius]\t[Range 1 lower] [Range 1 upper]\t[Range 2 lower] [Range 2 upper]...
A typical data line looks like this:
1.181 0 0 31.8196 38.3883 141.612 148.18 180 180 211.82 218.388 321.612 328.18
The number of ranges per line can differ, there are also lines without any ranges. Ideally I'd like to end up with a polar plot, where at a given radius the angle between the lower and upper limit of each range is filled, while the rest of the plot is empty.
The ranges do not overlap, but some of them have the same angle as lower and upper limit (for instance the "0 0" range in the example above), what should still be visible, as (as always) those single point and hardly-visible details in the calculation turned out to be those observed in experiment...
For now I've changed the C-program that outputs said ranges to give me a cloud of points with polar coordinates which I plot with dots, but I'd really prefer a kind-of vectorial plot with filled areas, as that'd mean (much) lower file size, and would allow zooming...
Any help would be appreciated, thanks in advance, Andreas
There are purely gnuplot 4.4+ solutions, but they will be intricate. One reason is that polar plotting of data files is not done with polar interpolation, but linear interpolation (straight lines between the endpoints). I would rather have the C program output the gnuplot commands to plot your data directly, e.g.
set polar
set angles degrees
plot (t<38.3883&t>31.8196)?1.181:1/0 with filledcurves above r=0, \
(t<...
I'd advise to treat the 0-range cases separately with set arrow from 0,0 to r*cos(angle),r*sin(angle).
I'm not sure the file will be so much smaller, again gnuplot will generate a polyline to approximate the arc of circle at r=1.181. If you want a small file with actual arcs of circle, you may want to generate svg code directly from your C code.

I want to make a scatter graph of the output of ftrace (from kernel)

I want to make a scatter graph of the output of ftrace (from kernel) on asm_do_IRQ..The problem is there are 8000+ entries and I get the results as a single line plot. Is there any way to do a normalisation of the values so that I can get a scatter plot? The values I want to print are as below:
Interrupt Time
uart-pl011 196.98111
Nomadi 196.983246
prcmu 196.983307
dma40 196.983429
dma40 196.984222
Nomadi 196.98642
dma40 196.988922
prcmu 196.988953
since the number of values are huge, excel takes time on the Y axis and plots the number of interrupts on the X axis. But i want the interrupts by name on the Y axis and time on the X axis.
looks like this is not possible. Scatter graphs can only be used to plot two variables, and since one of the axes i want to plot is a string, this is not possible - i can only get a trend, not the exact plots vs time

Resources