Plot data/samples on the map - python

What I am doing wrong here? I want to plot samples/data on top of my map(pixel plot).I have two different input data- one is for drawing a contour line, and another one I am using to plot samples on top of that contour map.
It can be seen here:

Related

Plotting points within a triangle

I'm using Python, and I have some data which can be projected on to points within an equilateral triangle whose side lengths sum to 1.
I'm not sure if there is an easy way to visualise a plot like this from Matplotlib or similar libraries, or if I'm just going to have to use a drawing package from scratch to make it happen. Any pointers gratefully recieved. Thanks!
If all you want to do is plot a few dots on a graph, you can infact use Matfplotlib's scatter plots for this:
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html
Using plt.xlim(*min*, *max*) and plt.ylim(*min*, *max*), you can set the limits of the graph manually to fit your values (might not be neccessary though).
You can draw lines on the graph for the triangle shape (if you need that): How to draw a line with matplotlib?
If you don't need a scale, you can even remove that to have a blank canvas: Matplotlib plots: removing axis, legends and white spaces

Generating seamless matplotlib contour plot

I'm using matplotlib and Python to generate a contour plot that I would like to make seamless across the X axis (meaning the contour regions will wrap at the right edge and align with the values from the left edge to create continuous regions). What is the best way to approach something like this?

How to add box plots on top of scatter plot

I want to plot boxplots on top of the scattered points like this.
I know I have to bin the data into intervals first but I couldn't find the function that does all of this. Sample x and y data are saved here as .npy.
I would look into using matplotlib. Boxes can be drawn as such:
https://matplotlib.org/gallery/pyplots/boxplot_demo_pyplot.html?highlight=boxplot
and scatter plots can also be drawn as such: https://matplotlib.org/gallery/lines_bars_and_markers/scatter_demo2.html?highlight=scatter
There is a search functionality on their site, along with plenty of documentation on how to utilize their library.
As for your specific question, you can specify zorder when drawing many of the things in matplotlib, and you could use that to define your boxplots to be on top. I believe if no zorder is defined that it draws items in the order they are encountered in your program (so you could draw scatter plots and then box plots and they should appear correctly as in your diagram above!

Removing invisible points from a scatter plot (Manhattan plot)

Consider a Manhattan plot for a genome-wide association study. The density of dots at the bottom of the plot is very high -- individual points are no longer visible. I'd like to skip plotting the points that completely overlap with other points (even though their x,y is not identical) to reduce the plotting time and the size of the exported PDF. Any recipes for achieving this? Collision detection? Subsampling?
I'd like to use matplotlib, though this requirement is optional. Ideally, the output should be visually identical to the "full" plot.
Some background info on the plot type:
https://en.wikipedia.org/wiki/Manhattan_plot

"continuous" plotting in Pygame

I do I plot a "continuous", moving plot in Pygame, like the plot in this "NetLogo" simulation? My main difficulty is not the plotting itself (lines between points) but the process of moving the framework of the plot when the curve getting close to the edge of the box.
Thank you.
Ok, so you can make a plot similar to the one in the application in the following way:
create a surface of the size of the graph. Then create a pixel array, so you will be able to modify the graph.
pxarray = pygame.PixelArray (surface)
you can then manipulate the array like any other array:
pxarray[x][y] = 0xFF00FF # this will set pixel at x,y to purple
you can normally then normally blit the surface to the screen.
more on pixel arrays : http://www.pygame.org/docs/ref/pixelarray.html
EDIT: Using pxarray, and transform you will have a shrinking graph if your numbers go out of range. Simply when the point is too big for the plot, you add enough rows, and use transform.scale to scale back to the original resolution.

Categories