Is there a way to draw a frequency distribution graph in python or R?
In R, using histograms, which show frequency on y axis vs some categorization on x-axis as in your example.
hist() function at the very least help you plot one vector (a set of values). ?hist for brief documentation, also search this site
how to plot two vectors side by side, similar to your posted example, an example is at http://www.cookbook-r.com/Graphs/Plotting_distributions_(ggplot2)/ , scroll down to Histogram and density plots with multiple groups
Related
One of my projects needs order analysis of vibration signals with Python instead of Matlab, they want to visualize data using colormap which usually has frequency on the horizontal axis and rotational speed on the vertical axis. Just like this picture:
How can I do this?
I Posted this question about 3D plots of data frames:
3D plot of 2d Pandas data frame
and the user referred me very very helfully to this:
Plotting Pandas Crosstab Dataframe into 3D bar chart
It use useful and the code worked in principle, but it lookes like a mess (see image below) for several reasons:
I have huge number of values to plot (470 or so, along the y-axis) so perhaps a bar chart is not the best way (I am going for a histogram kind of look, so I assumed very narrow bars would be suitable)
my counts (z axis) do not give almost any information, because the differences I need to see are from 100 to the max value
how can I make the 3D plot that shows up interactive? (being able to rotate etc) - I have seen it done in blogs/videos but sure if it's something on Tools -> Preferences that I can't find
So re: the second issue, simple enough, I tried to just change the limits of the zbar as I would for a 2D Plot, by incorporating:
ax.set_zlim([110,150])
just before the axis labels, but obviously this is the wrong way:
SO do I have to limit the values from the original data set (i.e. filter out <110), or is there a way to do this from the plot?
I am trying to generate a contour graph in terms of three parameters (say x, y, z). These parameters come from a data table of more than 5000 values.I need the graphics to look like the figures shown below.
Contour plots are most easily made using matplotlib's contour.
There's also a corresponding contourf function that provides filled contours. Anyway, what you uploaded looks more like matplotlib's pcolor or pcolormesh, as they draw colored pixels instead of isovalue lines.
Here's a nice comparison of both if you need to choose.
Edit: For (x,y,z) points that are not distributed on a grid (i.e. come from random samples), a working solution seems to be a combination of binned_statistic_2d and then either plt.pcolor or plt.contour.
I created a graph in MATLAB (see figure below) such that around every data point there is a data distribution plotted (grey area plots). The way I did it in MATLAB was to create a set of axes for every distribution curve and then plot the curves without showing those axes at every point of the data curve. I also used a command 'linkaxes' to set figure limits for all the curves at once.
I must say that this is far from an elegant solution and I had many troubles with saving this figure in the correct aspect ratio settings. All in all I couldn't find any other useful option in MATLAB.
Is there a more elegant solution for such types of graphs in Python? I am not that much interested in how to do the areas highlighted, but how to place a set of curves(distributions) exactly at the positions of the main data curve points.
Thank you!
I plot a 2D KDE with seaborn with:
ax = sns.kdeplot(scatter_all["s_zscore"], scatter_all["p_zscore"])
I want my levels of the density estimation to be meaningful, ie. I wan to mark confidence intervals. Basically I would like to obtain something very close to:
this answer but the data are not normalized and it has to stay that way.
Could someone please provide me an explanation where, how and why should I change the calculations for the levels? I am looking for a clear statistical explanation as said in my comment below.