How do I make it so that my x and y axes have consistent intervals with plotly?

11 Views Asked by At

So I'm trying to make a graph tool in python with plotly where the user enters data for the x and y axes and it produces a graph based on the data. However, when I enter data and it produces the graph, the x and y axes don't have consistent intervals. Does anyone know how I can make the intervals consistent so the graph is actually correct? Thanks in advance.

My code:

import plotly
import plotly.graph_objects as go
import pandas as pd

dataNum = int(input('How many items do you want on the x and y axis? '))

xAxis = []
yAxis = []

for i in range(dataNum):
    x = input('What number would you like to enter on the x axis? ')
    y = input('What number would you like to enter on the y axis? ')
    print('\n')

xAxis.append(x)
yAxis.append(y)

userData = {'X axis' : xAxis, 'Y axis' : yAxis}
df = pd.DataFrame(userData)
print(df)

data = [go.Scatter(x = df['X axis'], y = df['Y axis'])]

graph = go.Figure(data)

graph.show()

Here is an example of what I'm talking about
enter image description here

0

There are 0 best solutions below