Altair: Empty line plot

Created on 11 Jan 2019  路  3Comments  路  Source: altair-viz/altair

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

question

Most helpful comment

Your Mercado y variable has square brackets, which are used to refer to nested quantities. Rename your column and the chart should work.

All 3 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jtbaker picture jtbaker  路  3Comments

pabloinsente picture pabloinsente  路  3Comments

tonylee3399 picture tonylee3399  路  3Comments

SuperShinyEyes picture SuperShinyEyes  路  3Comments

breadbaron picture breadbaron  路  4Comments