Convert multiple 2D lines in heatmap to represent density in each cell - python

I have numerous 2D lines (x1,y1;x2,y2) and a bunch of lines crossed each other in a specific area of the map. I have plotted as below, but it may not be easy to interpret.
Is it possible to use these 2D lines in the form of heatmap, and represent the crossing density in each cell (like this flights path).
In other ways, each 2D line has a Z value, so we may use it as a color bar for that heatmap.
I have seen multiple heatmap plots using scatter data points but could not find any way for 2D lines. Example
Any suggestions will be appreciated.

Related

Slice plot in vtk

I have a polydata file containing 3D coordinates of the mesh (as vtkPoints) and temperature at each point as an attribute. I want to plot the temperature as a slice plot (at three elevations) over the geometry. I managed to get the data slices at different elevation using vtkClipPolyData function. However, I am unable to find a good example showing how to interpolate the value at each of these points and plot the data. Really appreciate if someone can help me on this.
I tried to render the clipped data directly by increasing the point size from actor property,
actor.GetProperty().SetPointSize(5)
however, this gives a pixelated plot. See plot here

3D plot of 2D pandas data frame - z-axis limits, interactivity

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?

How to make a contour plot with three variables in a dataset?

I am trying to generate a contour graph in terms of three parameters (say x, y, z). These parameters come from a data table of more than 5000 values.I need the graphics to look like the figures shown below.
Contour plots are most easily made using matplotlib's contour.
There's also a corresponding contourf function that provides filled contours. Anyway, what you uploaded looks more like matplotlib's pcolor or pcolormesh, as they draw colored pixels instead of isovalue lines.
Here's a nice comparison of both if you need to choose.
Edit: For (x,y,z) points that are not distributed on a grid (i.e. come from random samples), a working solution seems to be a combination of binned_statistic_2d and then either plt.pcolor or plt.contour.

Plotting multiple 3d scatterplots with matplotlib using same data but different viewing angles without scattering data for each subplot individually

I am trying to create a figure containing 3 subplots with 3d-scatterplots. All the scatterplots contain the same data, but I want to plot them using different azimuthal angle and elevation as is described in this question.
Because I have a large dataset, I would like to scatter the data only once instead of for every subplot individually and then use
ax.view_init(elev=XX., azim=YY)
on each subplot separately.
Is there a way to 'share the scatter data between subplots'?
This is more or less how I imagine the code to work:
read in data
create 3 empty subplots
scatter the data for first subplot
copy scattered data for second and third subplot
apply different angles with ax.view_init()

Maplotlib 3d imshow

I have a 3d array of data of which I am trying to do a visualization. The entries of the 3d array can only take boolean value. I would like to visualize it in way imshow offers to visualize a matrix by giving a color value to each entry. Here it is in 3d so I guess we should add some empty space between the points to see the inside.
I have looked into matplotlib 3d plots but I could not find the right tool for such visualization. What could I use?

Categories

Resources