Possible to apply markers to single data series?

Currently I am using Plotly express to plot a line chart with multiple data series. I can apply color, line dash etc to single data series without affecting others.

However, with markers, I cannot achive this. I need to set Marker to True which would apply markers to all of Data series and then change marker style or size for a single series. Is there a way I can apply a marker to a single data series without turning on markers for all of them?

        fig = px.line(
            data_frame=grouped_dff, 
            x='Time', 
            y='mean', 
            error_y = "std" if deviation_value in ["bar", "band"] else None,
            error_y_mode=deviation_value, 
            color=colorby, 
            line_dash=traceby, 
            color_discrete_sequence=color_sequence, 
            template=template,
	    height=600,
            markers = True if 2 in marker_input else False

        )

            renamed_series['settings'][method_new_name] = {
                'color': color_picker_value,
                'line_width': line_width,
                'line_dash': line_style,
                'marker_symbol': marker_style,
                'marker_size': marker_size
            }
        
            # Apply the changes to the selected series
            fig.data[selected_series_index].line.color = color_picker_value
            fig.data[selected_series_index].line.width = line_width
            fig.data[selected_series_index].line.dash = line_style
            fig.data[selected_series_index].marker.symbol = marker_style
            fig.data[selected_series_index].marker.size = marker_size

You should be able to do this by adding traces separately to the plot with the add_trace() method.

Ok, so plotly.graph_objs should be a way but probably I cannot do it in px? Would like to avoid that since I have many dcc stores connected to the px plot and transition to plotly go means I need to rewrite a lot of code.

I noticed that it can be done in DCE. I guess plotly.graph_objs are used there?

I don’t know if it can be done entirely in px, but you can create most of the plot in px, and then use add_trace to add the one that has to have markers , if it helps:

fig = px.line(...)
fig.add_trace(go.Scatter(x=[0.8, 1.2, 1.9],y=[1.7, 1.9, 1.2], mode='markers+lines'))
1 Like