Hi!
I'm making a line plot with some info.
When I do the plot in one column of data I get the expected result, but when I doit with the other column I dont get nothing, not even a error.
def grafico(tipo):
dict_var = {'Mercado': { 'x':'Fecha', 'x_title':'Trimestres', 'y':'% Mercado', 'y_title':'% Mercado',
'color':'Denominaci贸n'},
'Respuesta': { 'x':'Fecha', 'x_title':'Trimestres', 'y':'%\n[(Dispon.+ Invers.) /\nDeudas c/Aseg.]:Q', 'y_title':'Respuesta',
'color':'Denominaci贸n'} }
color = alt.Color(dict_var[tipo]['color'])
x = alt.X(dict_var[tipo]['x'], axis = alt.Axis(title = dict_var[tipo]['x_title'], grid = False))
y = alt.Y(dict_var[tipo]['y'], axis = alt.Axis(title = dict_var[tipo]['y_title'], grid = True))
chart = alt.Chart(source).mark_line().encode(
x = x, y = y, color = color
)
return chart
In this example I get the plot:
grafico('Respuesta')
In this I get nothing:
grafico('Mercado')
Both columns have the same type (float) and the same quantity of numbers.
The only diference I find it's in the second exaple there are a lot of negative values.
I leave the link for the git, so you can see all the code and the files:
GitHub
Your Mercado y variable has square brackets, which are used to refer to nested quantities. Rename your column and the chart should work.
See the discussion of the field argument here: https://altair-viz.github.io/user_guide/encoding.html#encoding-channel-options
Thnks for the aswer!
It is solved!
Most helpful comment
Your
Mercadoy variable has square brackets, which are used to refer to nested quantities. Rename your column and the chart should work.