Error in plotting subplots with six y axis (time series data)-Invalid value of type 'builtins.int' received for the 'domain[1]' property of layout.yaxis

Hi,
Iam newbie to plotly and not much competency in Python.Please help me resolve the six y axis plotting on time series data.Please help me to resolve the issue.


columns are

image

Please find the code block for the plotting function.

def plot_range_current_AC_status_temp(df,from_date,to_date):
      file_name = file_name = "Minute wise Phase wise power source wise & temperature trend with AC status "+str(from_date)+"  to   "+ str(to_date)
      fig = go.Figure()

      fig = make_subplots(rows=6, cols=1,
                          shared_xaxes=True,
                          vertical_spacing=0.16)
      fig.add_trace(go.Scatter(x=df['Date_time_ref'], y=df['EB_KW'],line = dict(color = "#FAFA48", width=1)),
                  row=1, col=1)
      fig.add_trace(go.Scatter(x=df['Date_time_ref'], y=df['DG_KW'],line = dict(color = "#122BFB", width=1)),
                  row=2, col=1)
     
      fig.add_trace(go.Scatter(x=df['Date_time_ref'], y=df['AC_Status'],line = dict(color = "#55A219", width=1)),
                  row=3, col=1)
      fig.add_trace(go.Scatter(x=df['Date_time_ref'], y=df['AC_Out_Temp'],line = dict(color = "#10CCE2", width=1)),
                  row=4, col=1)
      fig.add_trace(go.Scatter(x=df['Date_time_ref'], y=df['Room_Temp'],line = dict(color = "#EF4D0B", width=1)),
                  row=5, col=1)
      fig.add_trace(go.Scatter(x=df['Date_time_ref'], y=df['Ambient_Temp'],line = dict(color = "#EF4D0B", width=1)),
                  row=6, col=1)
      
      fig.update_layout(autosize=True,height=600, width=1000,
                        title_text= file_name,
                        xaxis_rangeslider_thickness = 0.1)

      fig.update_layout(
      xaxis=dict(
        autorange=True,
        range=[from_date,to_date],
        rangeslider=dict(
            autorange=True,
            range=[from_date,to_date]
                    ),
        type="date",
            ),
        yaxis=dict(
        anchor="x",
        autorange=True,
        domain=[0, 0.16],
        
        linecolor="#FAFA48",
        mirror=True,
        range=[df['EB_KW'].min(), df['EB_KW'].max()],
        showline=True,
        side="right",
        tickfont={"color": "#FAFA48"},
        tickmode="auto",
        ticks="",
        titlefont={"color": "#FAFA48"},
        type="linear",
        zeroline=True,
        title="EB_KW",
        position=0.0
        ),
        yaxis2=dict(
        anchor="x",
        autorange=True,
        domain=[0.16,0.32],
        linecolor="#122BFB",
        mirror=True,
        range=[df['DG_KW'].min(), df['DG_KW'].max()],
        showline=True,
        side="right",
        tickfont={"color": "#122BFB"},
        tickmode="auto",
        ticks="",
        titlefont={"color": "#122BFB"},
        type="linear",
        zeroline=True,
        title="DG_KW",
        
        ),
         yaxis3=dict(
        anchor="x",
        autorange=True,
        domain=[0.32,0.48],
        linecolor="#55A219",
        mirror=True,
        range=[df['AC_Status'].min(), df['AC_Status'].max()],
        showline=True,
        side="right",
        tickfont={"color": "#55A219"},
        tickmode="auto",
        ticks="",
        titlefont={"color": "#55A219"},
        type="linear",
        zeroline=True,
        title="AC-On/off",
        
        ),
        yaxis4=dict(
        anchor="x",
        autorange=True,
        domain=[0.48,0.64],
        linecolor="#10CCE2",
        mirror=True,
        range=[df['AC_Out_Temp'].min(), df['AC_Out_Temp'].max()],
        showline=True,
        side="right",
        tickfont={"color": "#10CCE2"},
        tickmode="auto",
        ticks="",
        titlefont={"color": "#10CCE2"},
        type="linear",
        zeroline=True,
        title="AC-Out_Temp",
        
        ),
         yaxis5=dict(
        anchor="x",
        autorange=True,
        domain=[0.64,8],
        linecolor="#EF4D0B",
        mirror=True,
        range=[df['Room_Temp'].min(), df['Room_Temp'].max()],
        showline=True,
        side="right",
        tickfont={"color": "#EF4D0B"},
        tickmode="auto",
        ticks="",
        titlefont={"color": "#EF4D0B"},
        type="linear",
        zeroline=True,
        title="Room_Temp",
        
        ),
        yaxis6=dict(
        anchor="x",
        autorange=True,
        domain=[0.8,1],
        linecolor="#EF4D0B",
        mirror=True,
        range=[df['Ambient_Temp'].min(), df['Ambient_Temp'].max()],
        showline=True,
        side="right",
        tickfont={"color": "#EF4D0B"},
        tickmode="auto",
        ticks="",
        titlefont={"color": "#EF4D0B"},
        type="linear",
        zeroline=True,
        title="Ambient_Temp",
        
        ),
      )
      fig.update_xaxes(automargin=True)
      fig.update_yaxes(automargin=True)
     

      # Update layout
      fig.update_layout(
          dragmode="zoom",
          hovermode="x",
          height=700,
          
          margin=dict(
              l=20,
              t=30,
              b=20,
              r=20,
              
              autoexpand=True
          ),
      )

            
      fig.show()
      fig.write_html(file_name+".html")

When i use the function as below:
plot_range_current_AC_status_temp(df_raw,from_date,to_date)

Getting this error as below.


ValueError                                Traceback (most recent call last)
<ipython-input-235-c7b62274df4b> in <cell line: 1>()
----> 1 plot_range_current_AC_status_temp(df_raw,from_date,to_date)

11 frames
<ipython-input-234-79b9f3123486> in plot_range_current_AC_status_temp(df, from_date, to_date)
     25                         xaxis_rangeslider_thickness = 0.1)
     26 
---> 27       fig.update_layout(
     28       xaxis=dict(
     29         autorange=True,

/usr/local/lib/python3.10/dist-packages/plotly/graph_objs/_figure.py in update_layout(self, dict1, overwrite, **kwargs)
    773 
    774         """
--> 775         return super(Figure, self).update_layout(dict1, overwrite, **kwargs)
    776 
    777     def for_each_trace(

/usr/local/lib/python3.10/dist-packages/plotly/basedatatypes.py in update_layout(self, dict1, overwrite, **kwargs)
   1391             The Figure object that the update_layout method was called on
   1392         """
-> 1393         self.layout.update(dict1, overwrite=overwrite, **kwargs)
   1394         return self
   1395 

/usr/local/lib/python3.10/dist-packages/plotly/basedatatypes.py in update(self, dict1, overwrite, **kwargs)
   5112             with self.figure.batch_update():
   5113                 BaseFigure._perform_update(self, dict1, overwrite=overwrite)
-> 5114                 BaseFigure._perform_update(self, kwargs, overwrite=overwrite)
   5115         else:
   5116             BaseFigure._perform_update(self, dict1, overwrite=overwrite)

/usr/local/lib/python3.10/dist-packages/plotly/basedatatypes.py in _perform_update(plotly_obj, update_obj, overwrite)
   3898                     # Update compound objects recursively
   3899                     # plotly_obj[key].update(val)
-> 3900                     BaseFigure._perform_update(plotly_obj[key], val)
   3901                 elif isinstance(validator, CompoundArrayValidator):
   3902                     if plotly_obj[key]:

/usr/local/lib/python3.10/dist-packages/plotly/basedatatypes.py in _perform_update(plotly_obj, update_obj, overwrite)
   3919                 else:
   3920                     # Assign non-compound value
-> 3921                     plotly_obj[key] = val
   3922 
   3923         elif isinstance(plotly_obj, tuple):

/usr/local/lib/python3.10/dist-packages/plotly/basedatatypes.py in __setitem__(self, prop, value)
   4849                 # ### Handle simple property ###
   4850                 else:
-> 4851                     self._set_prop(prop, value)
   4852             else:
   4853                 # Make sure properties dict is initialized

/usr/local/lib/python3.10/dist-packages/plotly/basedatatypes.py in _set_prop(self, prop, val)
   5193                 return
   5194             else:
-> 5195                 raise err
   5196 
   5197         # val is None

/usr/local/lib/python3.10/dist-packages/plotly/basedatatypes.py in _set_prop(self, prop, val)
   5188 
   5189         try:
-> 5190             val = validator.validate_coerce(val)
   5191         except ValueError as err:
   5192             if self._skip_invalid:

/usr/local/lib/python3.10/dist-packages/_plotly_utils/basevalidators.py in validate_coerce(self, v)
   2202             for i, (el, validator) in enumerate(zip(v, self.item_validators)):
   2203                 # Validate coerce elements
-> 2204                 v[i] = validator.validate_coerce(el)
   2205 
   2206         return v

/usr/local/lib/python3.10/dist-packages/_plotly_utils/basevalidators.py in validate_coerce(self, v)
    802             if self.has_min_max:
    803                 if not (self.min_val <= v <= self.max_val):
--> 804                     self.raise_invalid_val(v)
    805         return v
    806 

/usr/local/lib/python3.10/dist-packages/_plotly_utils/basevalidators.py in raise_invalid_val(self, v, inds)
    286                 name += "[" + str(i) + "]"
    287 
--> 288         raise ValueError(
    289             """
    290     Invalid value of type {typ} received for the '{name}' property of {pname}

ValueError: 
    Invalid value of type 'builtins.int' received for the 'domain[1]' property of layout.yaxis
        Received value: 8

    The 'domain[1]' property is a number and may be specified as:
      - An int or float in the interval [0, 1]

Thanks in Advance…

Hi @jaikishank welcome to the forums.

I think you have a typo here… 8 instead of 0.8

A side note: Could you please provide your data in a way that we can copy&paste it instead of images in future topics? This increases dramatically your chances of getting help from other users.

Apologies for the delayed response. Thanks AIMPED and shall ensure the same in my futher postings.

1 Like