I am plotting plotly scatter 3d in spyder IDE and it is working fine. Along with that, I am trying to save a particular camera view as png. This is where I am running issues into. This article (https://nbviewer.org/github/etpinard/plotly-misc-nbs/blob/master/3d-camera-controls.ipynb) I found after a few hours of search is quite useful in let me know the right numbers for a view I am trying and addressed my main problem. The reason I am writing this post here to address the minor problems: reducing the white space
My code:
import plotly.express as px
from plotly.offline import plot
import plotly
fig = px.scatter_3d(df, x=xlbl, y=ylbl, z=zlbl,
color=wlbl,opacity=0,
color_continuous_scale = plotly.colors.sequential.Viridis)
cat_labels = ["Fall", "Winter", "Spring", "Summer"]
fig.update_coloraxes(colorbar=dict(ticktext=cat_labels,
tickvals=list(range(1, len(cat_labels)+1))))
fig.update_layout(font=dict(size=12))
fig.update_layout(
width=400, height=400,
margin=dict(t=0, r=0, l=0, b=0
))
name = 'eye = (x:0., y:2.5, z:0.)'
camera = dict(
up=dict(x=0, y=0, z=1),
center=dict(x=0, y=0, z=0),
eye=dict(x=2, y=0.1, z=0.1)
)
fig.update_layout(scene_camera=camera,
# title=name
)
# save the present camera as a png file
fig.write_image("fig_name.png", scale=5,width=1)
# Render and save HTML interactive 3d plot
temp_name = 'Temp_plot.html'
plot(fig, filename = file_loc+'python_plots_manju//'+temp_name, auto_open=False,
image_width=1200,image_height=800
)
plot(fig)
Present PNG outputs:
Expected output:
- How to drop the white space in the above plots?
- How to control the gap between ticks and labels?
- In the above plot, I want to keep the same zoom position but slight rotation along y-axis? How to do it?

