Suppose I have the following data for five different categories:
I would like to create a figure showing the mean (and the 1-std.-band around the return) in something like the graph below (mean and std in y-axis, the different categories x-axis). Would it also be possible to add the Sharpe as a red/orange triangle in the same graph (with a secondary y-axis on right)?
Related
I am doing a study in school about the effect of noise in a person's environment and his/her activity.
I have two dataframes with data I would like to compare. The data was recorded at the same time, but the time intervals between measurements are different. This makes it hard for me to overlay a plot and look at possible correlations.
The data frames look like this:
Volume level:
steps:
When I try to put these two dataframes in one plot with a sync timeline, the steps graph looks way smaller than the volume level graph. I have tried to plot the two graphs in multiple ways, but I keep ending up with something like this:
How about this.
This code uses multi y axis so it will help you with your problem that the graph size doesn't fit.
ax = steps_Niels_1st["steps"].plot()
ax1 = ax.twinx()
ax = volume_data_Niels_1st['size'].plot(ax=ax1)
plt.show()
I'm drawing a Barplot in Python with matplotlib, and currently it looks as follows.
Briefly, I'm measuring a quantity called EOD under different settings (represented with different colors), and plotting the mean and std. dev. values for each setting over multiple measurements I've done.
The problem is, this EOD quantity can strictly take non-negative values so the area under 0 is misleading. I know this happens because for some settings (for example the blue one) the std. dev is larger than mean value. Still, I'd like to prevent this.
In short, how can I dock my bars to the bottom of the bounding box where it should start from 0?
ax.set_ylim(ymin=0)
did the trick as suggested by JohanC in the comments.
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've drawn a plot of 20 points on matplotlib
However, applying a '-o' parameter on the plot causes the plots to be connected in a weird order.
I would like it connected along the x axis (lowest x to highest x)
It currently looks like this
This is what it looks like with '-o'
Is there a way to force matplotlib to plot in increasing order of x values?
Yes.
Sort the points in increasing order of x-coordinates before giving those points to matplotlib, which simply connects the points in the order you give them to matplotlib.
(We could help you more if you show us the code, perhaps simplified, that gave you that bad example plot.)
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