Bokeh is a nice library, helping python web developers to visualise your data in the browser. It is on good terms with pandas, the statistical and data manipulation package beloved by data scientists. It can source points from a dataframe object directly. Unfortunately, it can't get a result of a group by object directly to display it as multiple lines, yet. But no worries, with just a few lines of code you can convince it to draw you a nice multiline graph. Take a look at the code snippet below:

from bokeh.plotting import figure
    from bokeh.palettes import Spectral11
    import itertools

    grouped = df.groupby(by=["A"])
    p = figure(width=750, height=350, title="Plot thickens")

    line_dash_styles = [[10, 0], [20, 1], [10, 1], [5, 1]]
    for group, color, line_dash in zip(grouped, itertools.cycle(Spectral11), itertools.cycle(line_dash_styles)):
        name, data = group
        p.line(source=data[["B", "C"]], x='B', y='C', color=color, legend=name, line_dash=line_dash)
Tags: computers
Categories: None |

0 comments have been posted.

Your email: we will send you a confirmation link to this address to confirm your identity and to prevent robot posting
Get in touch
»...«
Join notification list

Join the email list to get notified about new posts and other updates

Follow updates

Join our social networks and RSS feed to keep up to date with latest news and publications