I had developed scatter and lasso selection plots with Chaco. Now, I need to embed a BaseMap [with few markers on a map] onto the plot area side by side.
I created a BaseMap and tried to add to the traits_view; but it is failing with errors.
Please give me some pointers to achieve the same.
Chaco and matplotlib are completely different tools. Basemap has been built on top of matplotlib so it is not possible to add a Basemap map on a Chaco plot.
I'm afraid I couldn't find any mapping layer to go with Chaco. Is there a reason you cannot use matplotlib for you plot?
Related
I've just started learning Plotly.py after learning how slow Matplotlib may be on rendering 3d plots.
I'm working on trying to visualize the RGB color space as a scatter plot of size 256256256, giving each point its respective color.
First I prepare the data:
```
from itertools import product
all_rgb_pixels = [[r,g,b,"{:2X}{:2X}{:2X}".format(r,g,b)] for r,g,b in product(range(256), range(256), range(256))]
df = pd.DataFrame(all_rgb_pixels, columns=['r', 'g', 'b','color'])
Then I plot using plotly this way:
fig = px.scatter_3d(df, x='r', y='g', z='b', range_x=[0,255], range_y=[0,255], range_z=[0,255], color='color')
fig.show()
However, plotly fails to show my plot, and makes VSCode crash.
Is there a way to create high performance interactive plots in VSCode using plotly or do something to optimize the plotting process, so it doesn't crash?
Note:
I read this post however, didn't find a good answer that satisfied my needs.
I have a xarray dataset clip_ds and have visualised the data array using plot. Now, I want to add a country boundary using Basemap's drawcountries(). Apparently, there is something wrong with the extent I am using in basemap (I guess), but both the country border and the data plot won't show up together. I have tried interchanging the position of clip_ds.pr[0].plot() before and after I create basemap, and it gives me two different results as shown below:
Xarray PLOT BEFORE BASEMAP (Note that the colorbar from xarray plot is still there)
Xarray PLOT AFTER BASEMAP (Notice difference from 3, height of the plot shrinks here and the tick labels disappears, probably overlapped by basemap.)
Xarray plot only
Loading seperate shapefile using map.readshapefile also gives same kind of problem. I know there might be a way around this using cartopy, but I like the Basemap functionalities and would like to know if there is any solution to this.
map=Basemap(projection='merc',
resolution='l',
llcrnrlon=clip_ds.lon[0],
llcrnrlat=clip_ds.lat[0],
urcrnrlon=clip_ds.lon[-1],
urcrnrlat=clip_ds.lat[-1])
map.drawcountries()
clip_ds.pr[0].plot()
plt.show()
I am plotting the drift track of multiple buoys in the arctic. I need a map in the polar stereographic projection and then to plot many latitude/longitude pairs from a dataframe on the the map. What packages work with this. I thought that Folium looked really nice, but I don't think that it can do different projections. There is also basemap, cartopy...
Any thoughts?
Cartopy supports a north polar stereographic projection and can be used with matplotlib to create a map and plot datapoints. The Cartopy documentation includes examples of how to plot points on a map projection.
GeoViews supports NorthPolarStereo projection. GeoViews using a Bokeh extension support map interactivity like panning and zoom similar to Folium.
I am unsure whether this functionality is possible through Plotly or if it is achievable with other plotting packages so I am open to different solutions.
I am trying to plot two violin plots in a single figure where one violin is oriented horizontally while the other is vertical. I would like to specify the point at which they intersect (i.e the primary axis of each). Ideally each would be transparent and interactive.
Somewhat poor illustration of what I need
Thank you for any proposed solutions!
There are multiple Python libraries doing Violin Plots. Plotly is among them, check its manual.
Besides, Seaborn is really good at this:
It is a Python visualization library based on Matplotlib. The code snipped for the above example can be found in Seaborn's gallery.
I would like to plot multiple pie charts over an existing plot using absolute coordinates.
I went through the add_axes method and also the AxesGrid toolikt but couldn't find a solution.
To be more specific, I want to draw pie charts over a geographical map using the basemap module.
This tutorial explains how to use matplotlib Basemap for drawing pie charts on a map. It is fairly simple and gives code examples.