Hello,
Is there a way to use orthographic instead of perspective projection for 3D plots?
This is in fact the standard for Matlab for example, and it is very convenient when viewing data to have a 2D projection when the camera is looking along one of the axis of the plot, for example.
Even if this requires some modification of plotly.js, I’d be interested to be guided in the right direction, even though a release is not done right away.
Best regards,
Emmanuel
2 Likes
There’s no way to change the projections settings in our 3D subplots at the moment.
Feel free to open a feature request -> https://github.com/plotly/plotly.js/issues/new
When doing so, make sure to add links to and screenshots of the relevant matlab examples you mentioned above.
Hi, is there any update in this regard? Thank you
empet
March 20, 2021, 5:10pm
4
@carlomontec
Orthographic projection has been introduced in 2019.
I paste here the layout definition from a json file to see how the projection type is set:
"layout": {"scene":{
"camera": {
"projection": {
"type": "orthographic"
}
}}}
2 Likes
Thank you very much for the complete reply.
matan3
August 24, 2023, 2:01pm
6
Am I the only one getting a perspective scene tile in the background even when choosing type=‘orthographic’?
It’s hard to convince oneself with toy data below, that this argument works as expected:
import plotly.graph_objs as go
fig = go.Figure()
scatter3d = fig.add_scatter3d(
x=[0, 1, 2, 3],
y=["A", "B", "C", "B"],
z=[1, 3, 2, 1])
fig.layout.title.text = 'Perspective projection'
fig.show()
fig.layout.title.text = 'Orthographic projection'
fig.layout.scene.camera.projection.type = "orthographic"
fig.show()
adapted from: https://github.com/jonmmease/plotly.py_release_notebooks/blob/master/notebooks/v3.7.0/orthographic_projection.ipynb
AIMPED
August 24, 2023, 8:29pm
7
Hi, I think you are looking for camera controls:
Which is different to the projection type.
EDIT: I created a dash app for trial & error of camera adjustments, maybe interesting for someone searching for this topic.
import json
import dash
from dash import html, dcc, Input, Output, State, clientside_callback
import plotly.graph_objects as go
import pandas as pd
# Read data from a csv
z_data = pd.read_csv(
'https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv')
fig = go.Figure(
data=go.Surface(z=z_data.values),
layout=dict(
title='Mt Bruno Elevation',
autosize=True,
width=500,
height=500,
margin=dict(l=0, r=0, b=0, t=30),
template='plotly_dark',
This file has been truncated. show original
matan3
August 25, 2023, 5:47pm
8
Oh thank you. I was rather trying to convince myself that the orthographic view is really orthographic.