plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

pio.write_image is not showing markers on go.scatter graph

Open hohumsup opened this issue 6 years ago • 7 comments

Hi,

I am having issue with exporting this figure. It is not displaying the symbol on the scatter graph. Please see below:

This is how the figures looks on the dashboard. newplot (28)

But with the static image export via pio.write_image(), the figure does not show the symbol on the figure. CoSTAR_alpha_2_robot_activity

        mask_in = (robot_in_events['event_type__name']=='Ingress')
        res = list(compress(range(len(mask_in)), mask_in))
        for j in res:
            if not 'Ingress' in event_types:
                markers_in[j] = 'line-ew-open'
            else:
                markers_in[j] = 'triangle-right'

        mask_in = (robot_in_events['event_type__name']=='Gate Trip')
        res = list(compress(range(len(mask_in)), mask_in))
        for j in res:
            if not 'Gate Trip' in event_types:
                markers_in[j] = 'line-ew-open'
            else:
                markers_in[j] = 'x-open'

    trace0 = go.Scatter(
            x = xdata_in,
            y = ydata_in,
            name = 'robot',
            mode = 'lines+markers',
            marker = dict(
                size = 20,
                symbol = markers_in,
                line = dict(
                    width = 2,
                ),    
            ),
            hoverinfo = 'text',
            # text = 'Robot ID: ' + unique_robot_list[i-1] + '<br>',
            showlegend = False
        )
        
        data.append(trace0)

hohumsup avatar Mar 20 '20 09:03 hohumsup

That is quite strange... What version of orca are you running?

nicolaskruchten avatar Mar 20 '20 13:03 nicolaskruchten

Are you able to export the image from this example? https://plot.ly/python/marker-style/#custom-marker-symbols

Locally this works for me with Orca 1.3 and 1.2 as per the "status" section from https://plot.ly/python/orca-management/#status

nicolaskruchten avatar Mar 20 '20 14:03 nicolaskruchten

I was able to export the figure above with the symbol showing and I am running Orca1.2.1. I still can't figure out why the symbol won't show on my graph.

If I remove symbol = markers_in, I can see the default circles on my graph.

hohumsup avatar Mar 20 '20 18:03 hohumsup

It looks like the issue is caused by the for-loop on my markers... If I use markers = symbols, symbols.append(raw_symbols[i]) from the example you gave me, I can see the markers on my figure.

hohumsup avatar Mar 20 '20 18:03 hohumsup

Could you please share a bit more of your code? I'm having trouble understanding what markers_in is and how it's constructed :)

nicolaskruchten avatar Mar 20 '20 18:03 nicolaskruchten

@nicolaskruchten I figured it out! It looks like the if-not statement (see the commented out code below) on the markers was causing the issue. Any idea why that didn't affect the dashboard figure though, but only the export figure?

for i in range(1, robot_list_count+1):
        robot_in_mask = metadata['asset'] == unique_robot_list[i-1]
        entity_in_mask = robot_activity['entity'] == unique_robot_list[i-1]
        robot_in_events = robot_activity[robot_in_mask | entity_in_mask]
        
        idx_egress_in = np.flatnonzero(robot_in_events['event_type__name']=='Egress')
        idx_ingress_in = np.flatnonzero(robot_in_events['event_type__name']=='Ingress')

        robot_in_events.iloc[idx_egress_in]
        robot_in_events.iloc[idx_ingress_in]
        
        xdata_in = pd.Series()
        xdata_in = xdata_in.append(pd.to_datetime(robot_in_events['start_datetime'], utc=False).dt.tz_localize('US/Central'))
        xdata_in = xdata_in.dt.tz_convert('US/Pacific')
        ydata_in = np.ones(len(xdata_in)) * i
    
        markers_in = [42] * len(xdata_in)
       
        mask_in = (robot_in_events['event_type__name']=='Traversal of Note')
        res = list(compress(range(len(mask_in)), mask_in))
        for j in res:
            # if not 'Traversal of Note' in event_types:
            #     markers_in[j] = 141
            # else:
            markers_in[j] = 108

hohumsup avatar Mar 20 '20 19:03 hohumsup

Hi - we are currently trying to tidy up Plotly's public repositories to help us focus our efforts on things that will help users most. Since this issue has been sitting for several years, I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our backlog. Thanks for your help - @gvwilson

gvwilson avatar Jun 14 '24 13:06 gvwilson