question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Plots Layout Weird Behavior

See original GitHub issue

I have created a plot using multiple curves. Individual plots work fine. But when I try to display side by side it just mixes everything.

def get_line_chart(plot_data, agg, agg_by, variable_col, direction):
    curves_list = []
    xaix = sorted(plot_data[agg].dropna().drop_duplicates())
    
    for turnDirection, data in plot_data.groupby([variable_col]):
        curve = hv.Curve((data[agg], data[agg_by]), name=str(turnDirection), label=str(turnDirection)) \
            .opts(xlabel=agg, xrotation=90, ylabel=agg_by)
        curves_list.append(curve)

    from functools import reduce
    return reduce(lambda x, y: x * y, curves_list).opts(title=direction, width=700)

def create_plot(df1, maxIntersections, agg_present, agg_by, variable_col, outputFolder):
    plots = []
    for direction in ['East', 'West',  'North', 'South']:
        filtered_data = df1[df1["inboundDir"] == direction]
        plots.append(get_line_chart(filtered_data, agg_present[1], agg_by, variable_col, direction))
    from functools import reduce
    plot = hv.Layout(reduce(lambda x, y: x + y, plots)).cols(2)
    hv.save(plot, outputFolder + 'WorstIntersectionsAreaPlot{0}.html'.format(variable_col))
       

This is normal NORTH plot image

This is normal SOUTH plot image

When I try to merge in a single view using + operator suddenly the second plot mixed up.

image

If I add multiple plots, 1st one behaves normally, all others are mixed up.

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
philippjfrcommented, Aug 25, 2020

I’d also expect that using hvPlot all of your code reduces to some variation of:

df1.hvplot.line('timeBin', agg_by, by=variable_col, groupby="inboundDir", shared_axes=False).layout().cols(2)
1reaction
philippjfrcommented, Aug 25, 2020

As a separate note, this bit can be simplified from:

    from functools import reduce
    return reduce(lambda x, y: x * y, curves_list).opts(title=direction, width=700)

to:

    return hv.Overlay(curves_list).opts(title=direction, width=700)

and similarly you can just do:

plot = hv.Layout(plots).cols(2)
Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Strange behavior when plotting the same subplot ...
This specific case produce f1 and f2 just once each, on the diagonal. In more complex cases, we see highly irregular behavior.
Read more >
r - Strange behaviour with actionButton, when I try to display multiple ...
However strangely I saw that, when User clicks actionButton , only one plot is displaying over the screen. However at the time of...
Read more >
weird behavior of plot - Mathematica Stack Exchange
Sometimes I'm lazy or the code is temporary, and the constant is a number that appears in several places. In that case, I...
Read more >
Odd Plotting Behavior with lymphGate flowStats
I believe this is just a plotting problem. The positive population in the workFlow appears to be the correct one, despite the median...
Read more >
Problem with Plots or Graphics Device in the RStudio IDE
When legends, lines, text, or points are missing or "incorrectly" placed, this is often the result of R condensing the plot to fit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found