Tengo un gráfico de barras y me gustaría modificar en qué número comienza el eje Y.
Sé que estoy usando la librería plotly.graph_objs
pero no encontré el doc sobre eso así que intenté usar lo mismo que se puede encontrar en el doc de plotlyexpress. Intenté usar figure.update_yaxes(tick0=0.7, showticklabels=False)
:
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd
from os.path import abspath, dirname, join
from server import app
import numpy as np
...
traces = []
for i in range(len(dfc)):
if not np.isnan(dfc.iloc[i].values[0]):
trace = go.Bar(x=[dfc.iloc[i].name], y=[dfc.iloc[i].values[0]], name=df.iloc[i].name)
# trace_perceived = go.Bar(x=[dfc.iloc[i].values[0]], y=[-dfc.iloc[i].values[2]], name='Perceived')
traces.append(trace)
# traces.append(trace_perceived)
figure={
'data': traces,
'layout':
go.Layout(title='Score de similarité des descriptions avec leurs commentaires', barmode='stack')
}
figure.update_yaxes(tick0=0.7, showticklabels=False)
return figure
Pero me devuelve:
* Running on http://127.0.0.1:8051/ (Press CTRL+C to quit)
127.0.0.1 - - [22/Dec/2020 11:33:18] "←[37mGET / HTTP/1.1←[0m" 200 -
127.0.0.1 - - [22/Dec/2020 11:33:19] "←[37mGET /_dash-layout HTTP/1.1←[0m" 200 -
127.0.0.1 - - [22/Dec/2020 11:33:19] "←[37mGET /_dash-dependencies HTTP/1.1←[0m" 200 -
127.0.0.1 - - [22/Dec/2020 11:33:20] "←[37mPOST /_dash-update-component HTTP/1.1←[0m" 200 -
Exception on /_dash-update-component [POST]
Traceback (most recent call last):
File "C:\Users\antoi\PycharmProjects\Bass\venv\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\antoi\PycharmProjects\Bass\venv\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\antoi\PycharmProjects\Bass\venv\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\antoi\PycharmProjects\Bass\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\antoi\PycharmProjects\Bass\venv\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\antoi\PycharmProjects\Bass\venv\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\antoi\PycharmProjects\Bass\venv\lib\site-packages\dash\dash.py", line 1076, in dispatch
response.set_data(func(*args, outputs_list=outputs_list))
File "C:\Users\antoi\PycharmProjects\Bass\venv\lib\site-packages\dash\dash.py", line 1007, in add_context
output_value = func(*args, **kwargs) # %% callback invoked %%
File "C:\Users\antoi\PycharmProjects\Bass\pages\similarity.py", line 67, in update_graph
figure.update_yaxes(tick0=0.7, showticklabels=False)
AttributeError: 'dict' object has no attribute 'update_yaxes'
127.0.0.1 - - [22/Dec/2020 11:33:20] "←[35m←[1mPOST /_dash-update-component HTTP/1.1←[0m" 500 -