Separate system of coordinates for x and y - python

I am using matplotlib for plotting in my project. I have a time series on my chart and I would like to add a text annotation. However I would like it to be floating like this: x dimension of the text would be bound to data (e.g. certain date on x-axis like 2015-05-04) and y dimension bound to Axes coordinates system (e.g. top of the Axes object). Could you please help me accomplish something like this?

It seems like I found the solution: one should use blended transformation:
http://matplotlib.org/users/transforms_tutorial.html#blended-transformations

Related

Best tool to plot "streamlines"?

I wanna plot a velocity profile, this is what I have:
(https://i.stack.imgur.com/Z319A.png)
but I want something like this:
(https://i.stack.imgur.com/yGeP6.png)
Data set is X and Y coordinates (basically a grid, e.g. 256x256, containing every coordinate) 3rd column is velocity.
So far I only found out it's not achievable in Gnuplot so I suppose my next best option would be Python.
What would be the easiest way for this in python? I'm not even sure if what I need is indeed streamline plotting, I just want to achieve what is in the second photo attached.

How do I plot a contour plot of 3 column data

I have a 3 column irregular data in the format [X Y Z]. I am having difficulty in creating a contourf
plot for the same since it requires one to create a meshgrid and also that data be uniform among the grid.
I need some direction or hint to get started.
I am providing two ways in which you can create a contour/density plot for the data which is in 3-column format and irregular, as you have mentioned.
You can use Mathematica: see the documentation of ListDensityPlot. You can directly provide the data as, ListDensityPlot[{{x1,y1,f1},…,{xk,yk,fk}}], and this will plot the sought density plot.
There is also a simple way to do this in python: You can see the documentation of tricontourf, a module of matplotlib. Its functionality is similar to that of contourf, except that you give 1D arrays rather than the data in mesh grid format.

Revalue a plot axis

I'm plotting a Matrix with contourf, the Matrix is 883x883, the problem is that when plotting it the axis in the plots go from 0 to 883, but I would like to give it another values, more exactly, I'd like it to go from -20 to 20. How can I set that? I am very new in python, so I'd appreciate your help.
When you use contourf, you can provide the location of your data points using the optional X and Y arguments. This will only work as expected if your data is structured, meaning if you can generate a grid made of rectangles for which the nodes would represent the location of your data points. If this is not the case, then I would suggest using a triangulation and provide it to tricontourf.

How to make data points in a 3D python scatter plot look like "discs" instead of "spheres"

In a standard 3D python plot, each data point is, by default, represented as a sphere in 3D. For the data I'm plotting, the z-axis is very sensitive, while the x and y axes are very general, so is there a way to make each point on the scatter plot spread out over the x and y direction as it normally would with, for example, s=500, but not spread at all along the z-axis? Ideally this would look like a set of stacked discs, rather than overlapping spheres.
Any ideas? I'm relatively new to python and I don't know if there's a way to make custom data points like this with a scatter plot.
I actually was able to do this using the matplotlib.patches library, creating a patch for every data point, and then making it whatever shape I wanted with the help of mpl_toolkits.mplot3d.art3d.
You might look for something called "jittering". Take a look at
Matplotlib: avoiding overlapping datapoints in a "scatter/dot/beeswarm" plot
It works by adding random noise to your data.
Another way might be to reduce the variance of the data on your z-axis (e.g. applying a log-function) or adjusting the scale. You could do that with ax.set_zscale("log"). It is documented here http://matplotlib.org/mpl_toolkits/mplot3d/api.html#mpl_toolkits.mplot3d.axes3d.Axes3D.set_zscale

Plotting Complex Numbers in Python?

For a math fair project I want to make a program that will generate a Julia set fractal. To do this i need to plot complex numbers on a graph. Does anyone know how to do this? Remember I am using complex numbers, not regular coordinates. Thank You!
You could plot the real portion of the number along the X axis and plot the imaginary portion of the number along the Y axis. Plot the corresponding pixel with whatever color makes sense for the output of the Julia function for that point.
Julia set renderings are generally 2D color plots, with [x y] representing a complex starting point and the color usually representing an iteration count.

Categories