2D plot in python - python-3.x

I have 3 sets of data x,y,z where z represents the scan steps and z=50. Corresponding to z I have a each values of x and y. I want to plot a line or contour plot at 5th, 10th and 20th scan steps. Is it possible and which function should I use?

I don't fully understand how your data is organized, but Matplotlib is the easiest way to pop up a contour plot: see this for example:
http://matplotlib.org/examples/pylab_examples/contour_label_demo.html
If you remove the last past of that URL, you can browse the entire gallery for more examples, some of which may be closer to what you are try to do.
A more involved and more powerful alternative would be Chaco. You can refer to this example:
http://docs.enthought.com/chaco/user_manual/annotated_examples.html#contour-plot-py
Mayavi is for 3D plotting which doesn't seem to be what you are trying to do. If you are curious, checkout:
http://docs.enthought.com/mayavi/mayavi/
Hope this helps.

Related

Histogram in gnuplot - bins not separated one from another

Sorry for my English,
I would like to make a histogram in gnuplot, where bins are not separated one from another by vertical lines, something like it is shown in the following figure:
I usually use "plot [...] with boxes" command to make a histogram, but it leads to a histogram with such vertical lines, which make the histogram unclear for bigger number of bins in the plot.
My data consists of two values for every value of x.
My comment again as answer, according to the StackOverflow "rule": no answers in comments...
You are probably looking for:
plot ... with steps
Check help steps. You may also want to check this answer about steps.

Seaborn: Plot scatterplot over lineplot in same plot

I am trying to create one plot with one scatter and multiple lineplots.
For the points to be seen well, I need the scatterplot in the front.
However changing the order inside my code doesn't solve this. The
lineplots always cover the scatterplot. Any ideas?
Please help.
Use the zorder parameter when scatterplotting, e.g.
sns.scatterplot(x, y, ax=ax, color='orange', zorder=7)
You may need to adjust the zorder value depending on the number of elements in your plot.

how to plot one graph after another in jupyter notebook

I'm trying to generate plot for each department and security rating, but all get is just one plot with latest values retrieved from dictionary holder:
my code is here:
https://codeshare.io/aYleWY
how to get:
graph
graph
graph
... but not as a subplot?
EDIT:
Corrected the code, and corrected the bug which repeated same data everywhere, but my plots lost Y axis altogether, any idea why?
You may add the statement plt.figure() in the beginning of your last for-loop in order to create a new figure on each iteration. Good luck!

How to add a trendline (exponential) in R?

Okay, so I am working with the daily closings of the Dow Jones Industrial Average (DJIA) index from January 1979 to December 1989. I have successfully plotted the time-evolution of the index, but I am stumped as to how to add a trendline (specifically, exponential). You can get the data here:
http://research.stlouisfed.org/fred2/series/DJIA/downloaddata
I just downloaded it to Excel and then imported it to R as a csv file and plotted it.
In addition to that, how can I add a trendline at a specific place? Say, I wanted a trendline from the year 1985 to 1988?
If that's literally what you want to do (I suspect it isn't), then all you have to do is plot and add a curve with the specified function of x:
plot(y~x)
par(new=TRUE)
curve(0.0629*exp(0.0003*x))
If you actually want to fit a curve based on something you do in R, you'll have to generate some kind of model and then plot fitted values from that using basically the same thing but instead of curve you could use lines.

How can I plot the points of a curve?

I'm not great with Math at all and so-so with Excel. I have a requirement to calculate a series of values to apply as an offset for a price schedule. I know what I basically want to achieve with the offsets and how I want them to change across span of values but I don't know how I can plot these values or something close to it in Excel. For an idea of the curve I'm roughly trying to create you can plot these values:
0
20
30
35
38
39
39.5
40
40.5
40.75
41
41.125
41.25
Or if you don't want to use excel you can take a look at this chart image:
Now it was easy to quickly create that by entering some values and tweaking them to get a shape I roughly want, but I need 1000 data points! In other words, instead of the 13 point I provided above I would need 1000. This would be crazy to try and do manually.
I can think of two possible options:
Create the range of values with fewer points, then somehow
extrapolate that data set into more points. Maybe extrapolate isn't
correct but essentially convert 10 points of data into 1000
Interactively draw a curve and then have it plotted to values within
a defined min/max range
I've tried googling for help but I'm just coming up with tons and tons of "how to plot your data" sites - I need to work from the OTHER direction ;)
Thanks for any help or tips.
Like you said, you could draw a curve and plot those points, then put them into some equation solver to get an equation that could describe the curve you're looking for.
But just from looking at your curve above, you might be able to use an equation of the following form.
y = A - (B / x)
To make a curve similar to yours above, you might try...
y = 40 - (5 / x))
You can use a site like https://functionplotter.com/ to plot the function and play with the values of A and B until you have curve that you are satisfied with.
Is this kind of thing you are looking for?
spline interpolation in exel
XlXtrFun.xll
basically you already got 13 y's and 13 implict x's (1 to 13). You provide bunch of "x" values of small increment, like 0.01, 0.02, 0.03, ...,12.999 13.000, to this tool. then this tool will calculate y value for each of the ones. You will plot these as "x y scatter plot"
A simple and very accurate way is to plot the curve as an x-y scatter plot, and then fit a polynomial via Insert Trendline.
In this case a 4th order polynomial provides close to a perfect fit (R2 of .9973)
Y = -0.0139x4 + 0.4819x3 - 6.0607x2 + 33.026x - 26.718
You can also solve this without charts using LINEST, see Walkenbach's guide here. But charts provide the easiest reference

Resources