Filled Plot not Extending Fill to Y-axis?


#1

Hi-- I’m trying to make a graph with a shaded central area to show the accepted value limits.
However, as you can see in the image below, the shaded region is not extending all the way to the y-intercept. The lines for the upper and lower bounds are extended all the way, and I’m not sure why the shading isn’t following suit.

graph_q

Here’s a snippet of my code where I define the fill rules for each trace.

> figure = {
>             'data': [
>                 go.Scatter(
>                     x=x1, 
>                     y=y1,
>                     opacity=0.7,
>                     hoverinfo="text",
>                     textposition="top left",
>                     mode='markers',
>                     name='Assay Data',
>                     marker={
>                         'size':9,
>                         'line': {'width':0.5, 'color':'white'}
>                     }
>                 ),
>                 go.Scatter(
>                     x=x1,
>                     y=upper_limit,
>                     opacity=0.7,
>                     hoverinfo="text",
>                     fill='tonexty',
>                     textposition="top left",
>                     mode='lines',
>                     name='Upper Limit'
>                 ),
>                 go.Scatter(
>                     x=x1,
>                     y=lower_limit,
>                     opacity=0.7,
>                     fill='tonexty',
>                     hoverinfo="text",
>                     textposition="top left",
>                     mode='lines',
>                     name='Lower Limit'
>                 ),
>                 go.Scatter(
>                     x=x1,
>                     y=target,
>                     opacity=0.7,
>                     hoverinfo="text",
>                     textposition="top left",
>                     mode='lines',
>                     name='Target Value'
>                     )
>             ],

#2

@hmsflynn,I can recreate your issue by using un-ordered xaxis data to create my lines. If I sort the x data that I use to create the lines I get the result you’re expecting.

import plotly.offline as opy
import plotly.graph_objs as go

x = [1,-1,2]
y = [1.5, 1.7, 0.3]
# x_lines = sorted(x)
x_lines = x

opy.iplot([
    go.Scatter(x=x_lines, y=[2,2,2]),
    go.Scatter(x=x_lines, y=[1,1,1], fill='tonexty'),
    go.Scatter(x=x, y=y, mode='markers'),
    go.Scatter(x=x_lines, y=[0,0,0]),
])

It appears that Plotly’s fill attribute needs x data s.t x 1 < x 2 < x 3 … < x n in order to work properly.