I have been using this code for my continues parameters to plot the probability distributions. However, my parameter now is price that cant be below zero, I have been reading to see if I can customize the density function so it dsnt go into negative numbers but havnt really found an answer. Does anyone know if there is a way to bound the density function?
fig = plt.figure(figsize=(6,4))
sns.distplot(data2018[ 'price'], hist=False)
sns.distplot(data2020[ 'price'], hist=False)
fig.legend(labels=['2018','2020'], bbox_to_anchor=(0.9,0.85))
Related
I hope that you are doing well. I am currently trying to replicate a type of isotope plot that's common in my field. Essentially, it's the result of a compound-specific stable isotope analysis.
The x and y axes represent delta values that are plotted against isotopic references from animals (ellipses) to identify animals by their signature. The ellipses represent a 95% CI.
I'm a beginner in R. I've managed to get the scatter plot to work, but I don't understand how to create a CI ellipses with reference data. Would anyone here know how to do this?
enter image description here
I am currently working on curves generated in tensile tests of polymer specimens. Here, I try to generate a mean curve of five data sets generated at the same composition of the samples. Unfortunately, the resulting curve is not a function but has a vertical section which is why a simple smooth is not sufficient. Is there a way to fix the smoothed curve to a defined end point in R? Or an even better way that I did not see yet?
I already tried a geometric_smooth() from ggplot2 on all data points but it did not work as wished.
My current approach:
data <- read.csv("data.csv", header = TRUE, sep = ";")
ggplot(data, aes(y=stress, x=strain))+geom_point()+geom_smooth()
In the figure, you can see that the blue average curve does not fit the actual curves near their end points, probably due to the vertical sections. That's why I want to fix it to the mean end point. Additionally, I would like to fix it to (0|0) as the blue mean curve starts somewhere above it which does not fit the actual behaviour.
Im trying to get Gnuplot to plot the function arctan(0.0199/(0.000415+x)).
My code is
f(x)=atan(0.0199/(0.000415+x))
plot f(x) title "stuff",
bur for some reason Gnuplot seems to be interpreting the part inside the brackets as a factor, visible in the fact that the arctan doesen't reach the expected maximum of pi/2. I have added the final below.
The aformentioned Plot.
gnuplot is old! back in the day, monitor resolutions were much smaller. So, the default sampling rate was chosen to be 100. This means, whatever your xrange is, gnuplot will sample 100 points evenly distributed in your xrange. Many maxima and minima are missed because of this.
However, as #user8153 points out, set samples 10000 to the rescue. gnuplot will now sample 10,000 x values in your xrange. 10000 is a good number but smaller will do. Experiment, at 5000, it looks like the function reached pi/2. At 1000 you can see it does not make it.
set yrange [0:2]
set samples 10000
f(x)=atan(0.0199/(0.000415+x))
plot f(x) title "stuff"
replot pi/2
Please be tolerant :) I am a dummy user of R and I am using the code and sample data to learn how to make forest plot that was shown in the previous post -
Optimal/efficient plotting of survival/regression analysis results
I was wondering is it possible to set user-defined x-axis scale with the code shown there? Up to now x a-axis scale is defined somehow automatically.
Thank you for any tips.
I'm unimpressed with the precision of the documentation since one might assume that the limits argument would be values on the relative risk scale rather than on the log-transformed scale. One gets a ridiculous result if that is done. That quibble not withstanding, it's relatively easy to use that parameter to created an expanded plot:
install('devtools') # then use it to get current package
# executing the install and load of the package referenced at the top of that answer
print(forest_model(lung_cox, limits=log( c(.5, 50) ) ))
Trying for a lower range of 0 on the relative risk scale is not sensible. Would imply a -Inf value on hte log-transformed scale. Trying for lower value, say log(0.001), confuses the pretty printing of the scale in my tests.
I have an R plot that looks like this:
The redline is the attempted smoothing with lines(smooth.spline(x, y, spar=0.000001)). Notice the insanely low spar value that STILL fails to include the spike near the end of the graph. Nevertheless, it is because of the number of points plotted: 107350. The 20 points near the end are unable to sway, although it is clearly noticeable that these are different than the rest.
What kind of R smoothing function could I use that encompasses these points?
Or if a smoother won't do it, how would I be able to "statistically" distinguish these points?