0

so - using Jupyter-lab - create a figure in matplot3d - and out of the box, if I just say "figure" (the name of my figure variable) - it magically renders something - something underneath is turning into a png - which is great

[Example1

the thing is though - I'd like it to be much bigger. And ideally draw lines so I can see the edges of the figure - potentially even have a light source. But the main thing is.... bigger

As much as I google, I can't find anything that controls how big that thing is rendered, or anything else about it, so any help would be appreciated - I keep finding examples of 2d renders, but I can't find much documentation showing Matplotlib can even do 3d, let alone tell me how to control how it does that.

Darren Oakey
  • 2,894
  • 3
  • 29
  • 55
  • setting the figure size works independently of what is in the figure (2D or 3D or no plot at all): `plt.rcParams["figure.figsize"] = (20, 10)` or `fig = plt.figure(figsize=(20, 10)` – Stef Aug 17 '22 at 10:27
  • Plus keep in mind if you are doing this a Jupyter notebook, it often won't render the full resolution in the cell's output. In such cases, you need to also use [.savefig()](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html), like `plt.savefig(my_plot.png)` to separately save the image as png, for example, and open that image file separately. (If you are using JupyterLab, you can just double click the image file in the file browser navigation pane and open it in full glory.) – Wayne Aug 17 '22 at 18:43
  • As for a lightsource, see the example in the documentation: https://matplotlib.org/stable/gallery/mplot3d/custom_shaded_3d_surface.html?highlight=lightsource . If you aren't needing the features of matplotlib necessarily and want to be in the Python ecosystem, for 3D there's also plotly and plotnine, see [here](https://stackoverflow.com/q/53706764/8508004) or [ipyvolume](https://ipyvolume.readthedocs.io/en/latest/#Mesh-plot) or VPython or [VTK](https://twitter.com/trung_leduc/status/1501523406843437057). – Wayne Aug 17 '22 at 19:00
  • Plus, k3d, see [the k3D repo](https://github.com/K3D-tools/K3D-jupyter/#k3d-jupyter) and a plot example in a notebook running [here](https://mybinder.org/v2/gh/fomightez/3Dsurface_plot-binder/HEAD?labpath=k3d_surface_examples.ipynb). Click `Run All` when the notebook comes up. – Wayne Aug 17 '22 at 19:09
  • thanks - will give k3d a go - I like the fact the plot is interactive. – Darren Oakey Aug 17 '22 at 22:24
  • I thought of this later...[this example](https://stackoverflow.com/a/73158943/8508004) serves to illustrate my advice about saving a figure separately and opening the plots outside Jupyter to appreciate the full resolution of the image that can be made. I suggest this process at the bottom of that post, too. Those many plots are much more readable in the saved image file than what is shown in the Jupyter notebook. – Wayne Aug 18 '22 at 17:51

0 Answers0