To add a horizontal line (axhline
) to a Plotly 3D express plot in Python, you can use the scatter.
First, create a 3D scatter plot using express:
main.py161 chars5 lines
Then, to add axhline
, you can create a new trace with the desired y-value:
main.py358 chars7 lines
In the code above, we created a new trace with the desired y-value, using minimal and maximal sepal_length
and petal_width
. Here we assumed that the data is sorted and continuous.
Now the figure fig
includes the desired axhline
trace.
Finally, we can use fig.show()
to show the plot.
main.py11 chars2 lines
gistlibby LogSnag