Hi,
I’ve been trying to plot a circle in plotly through a simple graph in python, but the result is an ellipsis instead of a circle. Although the values in the x-axis and y-axis are both correct, the image that appears to me is not a circle, as you can see.
Here’s the code:
import numpy as np
import plotly.plotly as py
import plotly.graph_objs as go
# Polar Coordinates
r = 1
theta = np.linspace(0, 2*np.pi, 200)
x_circle = 1 + r*np.cos(theta)
y_circle = 1 + r*np.sin(theta)
# It plots the points of the list outside the circle
trace = go.Scatter(
x=x_circle,
y=y_circle,
name='Circle',
mode='lines',
line=dict(
width=1.0,
color='rgba(66, 28, 82, 0.9)'
)
)
data = [trace]
# It sends authentication
py.sign_in('*******', '**********') # Intentionally hidden
# It plots scatter
py.plot(data, filename='basic-scatter')
@dieuler Your plot is an ellipse because you didn’t set the width and height of the plot rectangle. In this case the width is 700, and height 450, by default. To get a circle define the dict layout as follows:
You should tune the height until the plot looks like a circle. In my notebook, with height=650 it’s OK. This supplementary height is necessary because from the total height, 100px are reserved by the default top margin. Details on the default settings in layout can be found here: https://plot.ly/python/reference/#layout.