Matplotlib Plot throws an error

Hi,

I’m trying to log a matplotlib graph on Wandb and it throws the following error.

AttributeError: 'XAxis' object has no attribute '_gridOnMajor'

Steps to reproduce:
Following example: Log Plots - Documentation

Exact steps:

imports

import wandb
import random
import math

Login:

wandb.login()

Create and upload graph

# Start a new run
run = wandb.init(project='custom-charts')
offset = random.random()

import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4])
plt.ylabel("some interesting numbers")
wandb.log({"chart": plt})

# Finally, end the run. We only need this ine in Jupyter notebooks.
run.finish()

Summary error message:

AttributeError                            Traceback (most recent call last)
/home/ubuntu/src/workspace/py-vision/src/research/nbs/automated_inventory_analysis/aia_africaai_baseline/wanb_plot_test.ipynb Cell 4 in <cell line: 9>()
      7 plt.plot([1, 2, 3, 4])
      8 plt.ylabel("some interesting numbers")
----> 9 wandb.log({"chart": plt})
     11 # Finally, end the run. We only need this ine in Jupyter notebooks.
     12 run.finish()

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:256, in _run_decorator._noop.<locals>.wrapper(self, *args, **kwargs)
    253         wandb.termwarn(message, repeat=False)
    254         return cls.Dummy()
--> 256 return func(self, *args, **kwargs)

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:222, in _run_decorator._attach.<locals>.wrapper(self, *args, **kwargs)
    220         raise e
    221     cls._is_attaching = ""
--> 222 return func(self, *args, **kwargs)

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:1548, in Run.log(self, data, step, commit, sync)
   1541 if sync is not None:
   1542     deprecate.deprecate(
   1543         field_name=deprecate.Deprecated.run__log_sync,
   1544         warning_message=(
   1545             "`sync` argument is deprecated and does not affect the behaviour of `wandb.log`"
   1546         ),
   1547     )
-> 1548 self._log(data=data, step=step, commit=commit)

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:1339, in Run._log(self, data, step, commit)
   1336 if any(not isinstance(key, str) for key in data.keys()):
   1337     raise ValueError("Key values passed to `wandb.log` must be strings.")
-> 1339 self._partial_history_callback(data, step, commit)
   1341 if step is not None:
   1342     if os.getpid() != self._init_pid or self._is_attached:

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:1228, in Run._partial_history_callback(self, row, step, commit)
   1225 if self._backend and self._backend.interface:
   1226     not_using_tensorboard = len(wandb.patched["tensorboard"]) == 0
-> 1228     self._backend.interface.publish_partial_history(
   1229         row,
   1230         user_step=self._step,
   1231         step=step,
   1232         flush=commit,
   1233         publish_step=not_using_tensorboard,
   1234     )

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/interface/interface.py:541, in InterfaceBase.publish_partial_history(self, data, user_step, step, flush, publish_step, run)
    530 def publish_partial_history(
    531     self,
    532     data: dict,
   (...)
    537     run: Optional["Run"] = None,
    538 ) -> None:
    539     run = run or self._run
--> 541     data = history_dict_to_json(run, data, step=user_step, ignore_copy_err=True)
    542     data.pop("_step", None)
    544     partial_history = pb.PartialHistoryRequest()

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/data_types/utils.py:54, in history_dict_to_json(run, payload, step, ignore_copy_err)
     50         payload[key] = history_dict_to_json(
     51             run, val, step=step, ignore_copy_err=ignore_copy_err
     52         )
     53     else:
---> 54         payload[key] = val_to_json(
     55             run, key, val, namespace=step, ignore_copy_err=ignore_copy_err
     56         )
     58 return payload

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/data_types/utils.py:82, in val_to_json(run, key, val, namespace, ignore_copy_err)
     79     val = wandb.Table(dataframe=val)
     81 elif util.is_matplotlib_typename(typename) or util.is_plotly_typename(typename):
---> 82     val = Plotly.make_plot_media(val)
     83 elif isinstance(val, Sequence) and all(isinstance(v, WBValue) for v in val):
     84     assert run

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/data_types/plotly.py:48, in Plotly.make_plot_media(cls, val)
     46     if util.matplotlib_contains_images(val):
     47         return Image(val)
---> 48     val = util.matplotlib_to_plotly(val)
     49 return cls(val)

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/util.py:565, in matplotlib_to_plotly(obj)
    557 obj = ensure_matplotlib_figure(obj)
    558 tools = get_module(
    559     "plotly.tools",
    560     required=(
   (...)
    563     ),
    564 )
--> 565 return tools.mpl_to_plotly(obj)

File ~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/plotly/tools.py:112, in mpl_to_plotly(fig, resize, strip_style, verbose)
    110 if matplotlylib:
    111     renderer = matplotlylib.PlotlyRenderer()
...
--> 246     if axis._gridOnMajor and len(gridlines) > 0:
    247         color = export_color(gridlines[0].get_color())
    248         alpha = gridlines[0].get_alpha()

AttributeError: 'XAxis' object has no attribute '_gridOnMajor'

Full Error message:

{
	"name": "AttributeError",
	"message": "'XAxis' object has no attribute '_gridOnMajor'",
	"stack": "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)\n\u001b[1;32m/home/ubuntu/src/workspace/py-vision/src/research/nbs/automated_inventory_analysis/aia_africaai_baseline/wanb_plot_test.ipynb Cell 4\u001b[0m in \u001b[0;36m<cell line: 9>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      <a href='vscode-notebook-cell://ssh-remote%2Bai_training_g5/home/ubuntu/src/workspace/py-vision/src/research/nbs/automated_inventory_analysis/aia_africaai_baseline/wanb_plot_test.ipynb#W5sdnNjb2RlLXJlbW90ZQ%3D%3D?line=6'>7</a>\u001b[0m plt\u001b[39m.\u001b[39mplot([\u001b[39m1\u001b[39m, \u001b[39m2\u001b[39m, \u001b[39m3\u001b[39m, \u001b[39m4\u001b[39m])\n\u001b[1;32m      <a href='vscode-notebook-cell://ssh-remote%2Bai_training_g5/home/ubuntu/src/workspace/py-vision/src/research/nbs/automated_inventory_analysis/aia_africaai_baseline/wanb_plot_test.ipynb#W5sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>\u001b[0m plt\u001b[39m.\u001b[39mylabel(\u001b[39m\"\u001b[39m\u001b[39msome interesting numbers\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m----> <a href='vscode-notebook-cell://ssh-remote%2Bai_training_g5/home/ubuntu/src/workspace/py-vision/src/research/nbs/automated_inventory_analysis/aia_africaai_baseline/wanb_plot_test.ipynb#W5sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>\u001b[0m wandb\u001b[39m.\u001b[39;49mlog({\u001b[39m\"\u001b[39;49m\u001b[39mchart\u001b[39;49m\u001b[39m\"\u001b[39;49m: plt})\n\u001b[1;32m     <a href='vscode-notebook-cell://ssh-remote%2Bai_training_g5/home/ubuntu/src/workspace/py-vision/src/research/nbs/automated_inventory_analysis/aia_africaai_baseline/wanb_plot_test.ipynb#W5sdnNjb2RlLXJlbW90ZQ%3D%3D?line=10'>11</a>\u001b[0m \u001b[39m# Finally, end the run. We only need this ine in Jupyter notebooks.\u001b[39;00m\n\u001b[1;32m     <a href='vscode-notebook-cell://ssh-remote%2Bai_training_g5/home/ubuntu/src/workspace/py-vision/src/research/nbs/automated_inventory_analysis/aia_africaai_baseline/wanb_plot_test.ipynb#W5sdnNjb2RlLXJlbW90ZQ%3D%3D?line=11'>12</a>\u001b[0m run\u001b[39m.\u001b[39mfinish()\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:256\u001b[0m, in \u001b[0;36m_run_decorator._noop.<locals>.wrapper\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m    253\u001b[0m         wandb\u001b[39m.\u001b[39mtermwarn(message, repeat\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m)\n\u001b[1;32m    254\u001b[0m         \u001b[39mreturn\u001b[39;00m \u001b[39mcls\u001b[39m\u001b[39m.\u001b[39mDummy()\n\u001b[0;32m--> 256\u001b[0m \u001b[39mreturn\u001b[39;00m func(\u001b[39mself\u001b[39;49m, \u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:222\u001b[0m, in \u001b[0;36m_run_decorator._attach.<locals>.wrapper\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m    220\u001b[0m         \u001b[39mraise\u001b[39;00m e\n\u001b[1;32m    221\u001b[0m     \u001b[39mcls\u001b[39m\u001b[39m.\u001b[39m_is_attaching \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m--> 222\u001b[0m \u001b[39mreturn\u001b[39;00m func(\u001b[39mself\u001b[39;49m, \u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:1548\u001b[0m, in \u001b[0;36mRun.log\u001b[0;34m(self, data, step, commit, sync)\u001b[0m\n\u001b[1;32m   1541\u001b[0m \u001b[39mif\u001b[39;00m sync \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m   1542\u001b[0m     deprecate\u001b[39m.\u001b[39mdeprecate(\n\u001b[1;32m   1543\u001b[0m         field_name\u001b[39m=\u001b[39mdeprecate\u001b[39m.\u001b[39mDeprecated\u001b[39m.\u001b[39mrun__log_sync,\n\u001b[1;32m   1544\u001b[0m         warning_message\u001b[39m=\u001b[39m(\n\u001b[1;32m   1545\u001b[0m             \u001b[39m\"\u001b[39m\u001b[39m`sync` argument is deprecated and does not affect the behaviour of `wandb.log`\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m   1546\u001b[0m         ),\n\u001b[1;32m   1547\u001b[0m     )\n\u001b[0;32m-> 1548\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_log(data\u001b[39m=\u001b[39;49mdata, step\u001b[39m=\u001b[39;49mstep, commit\u001b[39m=\u001b[39;49mcommit)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:1339\u001b[0m, in \u001b[0;36mRun._log\u001b[0;34m(self, data, step, commit)\u001b[0m\n\u001b[1;32m   1336\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39many\u001b[39m(\u001b[39mnot\u001b[39;00m \u001b[39misinstance\u001b[39m(key, \u001b[39mstr\u001b[39m) \u001b[39mfor\u001b[39;00m key \u001b[39min\u001b[39;00m data\u001b[39m.\u001b[39mkeys()):\n\u001b[1;32m   1337\u001b[0m     \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mKey values passed to `wandb.log` must be strings.\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m-> 1339\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_partial_history_callback(data, step, commit)\n\u001b[1;32m   1341\u001b[0m \u001b[39mif\u001b[39;00m step \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m   1342\u001b[0m     \u001b[39mif\u001b[39;00m os\u001b[39m.\u001b[39mgetpid() \u001b[39m!=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_init_pid \u001b[39mor\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_is_attached:\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/wandb_run.py:1228\u001b[0m, in \u001b[0;36mRun._partial_history_callback\u001b[0;34m(self, row, step, commit)\u001b[0m\n\u001b[1;32m   1225\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_backend \u001b[39mand\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_backend\u001b[39m.\u001b[39minterface:\n\u001b[1;32m   1226\u001b[0m     not_using_tensorboard \u001b[39m=\u001b[39m \u001b[39mlen\u001b[39m(wandb\u001b[39m.\u001b[39mpatched[\u001b[39m\"\u001b[39m\u001b[39mtensorboard\u001b[39m\u001b[39m\"\u001b[39m]) \u001b[39m==\u001b[39m \u001b[39m0\u001b[39m\n\u001b[0;32m-> 1228\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_backend\u001b[39m.\u001b[39;49minterface\u001b[39m.\u001b[39;49mpublish_partial_history(\n\u001b[1;32m   1229\u001b[0m         row,\n\u001b[1;32m   1230\u001b[0m         user_step\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_step,\n\u001b[1;32m   1231\u001b[0m         step\u001b[39m=\u001b[39;49mstep,\n\u001b[1;32m   1232\u001b[0m         flush\u001b[39m=\u001b[39;49mcommit,\n\u001b[1;32m   1233\u001b[0m         publish_step\u001b[39m=\u001b[39;49mnot_using_tensorboard,\n\u001b[1;32m   1234\u001b[0m     )\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/interface/interface.py:541\u001b[0m, in \u001b[0;36mInterfaceBase.publish_partial_history\u001b[0;34m(self, data, user_step, step, flush, publish_step, run)\u001b[0m\n\u001b[1;32m    530\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mpublish_partial_history\u001b[39m(\n\u001b[1;32m    531\u001b[0m     \u001b[39mself\u001b[39m,\n\u001b[1;32m    532\u001b[0m     data: \u001b[39mdict\u001b[39m,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    537\u001b[0m     run: Optional[\u001b[39m\"\u001b[39m\u001b[39mRun\u001b[39m\u001b[39m\"\u001b[39m] \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m,\n\u001b[1;32m    538\u001b[0m ) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m    539\u001b[0m     run \u001b[39m=\u001b[39m run \u001b[39mor\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_run\n\u001b[0;32m--> 541\u001b[0m     data \u001b[39m=\u001b[39m history_dict_to_json(run, data, step\u001b[39m=\u001b[39;49muser_step, ignore_copy_err\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m)\n\u001b[1;32m    542\u001b[0m     data\u001b[39m.\u001b[39mpop(\u001b[39m\"\u001b[39m\u001b[39m_step\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39mNone\u001b[39;00m)\n\u001b[1;32m    544\u001b[0m     partial_history \u001b[39m=\u001b[39m pb\u001b[39m.\u001b[39mPartialHistoryRequest()\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/data_types/utils.py:54\u001b[0m, in \u001b[0;36mhistory_dict_to_json\u001b[0;34m(run, payload, step, ignore_copy_err)\u001b[0m\n\u001b[1;32m     50\u001b[0m         payload[key] \u001b[39m=\u001b[39m history_dict_to_json(\n\u001b[1;32m     51\u001b[0m             run, val, step\u001b[39m=\u001b[39mstep, ignore_copy_err\u001b[39m=\u001b[39mignore_copy_err\n\u001b[1;32m     52\u001b[0m         )\n\u001b[1;32m     53\u001b[0m     \u001b[39melse\u001b[39;00m:\n\u001b[0;32m---> 54\u001b[0m         payload[key] \u001b[39m=\u001b[39m val_to_json(\n\u001b[1;32m     55\u001b[0m             run, key, val, namespace\u001b[39m=\u001b[39;49mstep, ignore_copy_err\u001b[39m=\u001b[39;49mignore_copy_err\n\u001b[1;32m     56\u001b[0m         )\n\u001b[1;32m     58\u001b[0m \u001b[39mreturn\u001b[39;00m payload\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/data_types/utils.py:82\u001b[0m, in \u001b[0;36mval_to_json\u001b[0;34m(run, key, val, namespace, ignore_copy_err)\u001b[0m\n\u001b[1;32m     79\u001b[0m     val \u001b[39m=\u001b[39m wandb\u001b[39m.\u001b[39mTable(dataframe\u001b[39m=\u001b[39mval)\n\u001b[1;32m     81\u001b[0m \u001b[39melif\u001b[39;00m util\u001b[39m.\u001b[39mis_matplotlib_typename(typename) \u001b[39mor\u001b[39;00m util\u001b[39m.\u001b[39mis_plotly_typename(typename):\n\u001b[0;32m---> 82\u001b[0m     val \u001b[39m=\u001b[39m Plotly\u001b[39m.\u001b[39;49mmake_plot_media(val)\n\u001b[1;32m     83\u001b[0m \u001b[39melif\u001b[39;00m \u001b[39misinstance\u001b[39m(val, Sequence) \u001b[39mand\u001b[39;00m \u001b[39mall\u001b[39m(\u001b[39misinstance\u001b[39m(v, WBValue) \u001b[39mfor\u001b[39;00m v \u001b[39min\u001b[39;00m val):\n\u001b[1;32m     84\u001b[0m     \u001b[39massert\u001b[39;00m run\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/sdk/data_types/plotly.py:48\u001b[0m, in \u001b[0;36mPlotly.make_plot_media\u001b[0;34m(cls, val)\u001b[0m\n\u001b[1;32m     46\u001b[0m     \u001b[39mif\u001b[39;00m util\u001b[39m.\u001b[39mmatplotlib_contains_images(val):\n\u001b[1;32m     47\u001b[0m         \u001b[39mreturn\u001b[39;00m Image(val)\n\u001b[0;32m---> 48\u001b[0m     val \u001b[39m=\u001b[39m util\u001b[39m.\u001b[39;49mmatplotlib_to_plotly(val)\n\u001b[1;32m     49\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mcls\u001b[39m(val)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/wandb/util.py:565\u001b[0m, in \u001b[0;36mmatplotlib_to_plotly\u001b[0;34m(obj)\u001b[0m\n\u001b[1;32m    557\u001b[0m obj \u001b[39m=\u001b[39m ensure_matplotlib_figure(obj)\n\u001b[1;32m    558\u001b[0m tools \u001b[39m=\u001b[39m get_module(\n\u001b[1;32m    559\u001b[0m     \u001b[39m\"\u001b[39m\u001b[39mplotly.tools\u001b[39m\u001b[39m\"\u001b[39m,\n\u001b[1;32m    560\u001b[0m     required\u001b[39m=\u001b[39m(\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    563\u001b[0m     ),\n\u001b[1;32m    564\u001b[0m )\n\u001b[0;32m--> 565\u001b[0m \u001b[39mreturn\u001b[39;00m tools\u001b[39m.\u001b[39;49mmpl_to_plotly(obj)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/plotly/tools.py:112\u001b[0m, in \u001b[0;36mmpl_to_plotly\u001b[0;34m(fig, resize, strip_style, verbose)\u001b[0m\n\u001b[1;32m    110\u001b[0m \u001b[39mif\u001b[39;00m matplotlylib:\n\u001b[1;32m    111\u001b[0m     renderer \u001b[39m=\u001b[39m matplotlylib\u001b[39m.\u001b[39mPlotlyRenderer()\n\u001b[0;32m--> 112\u001b[0m     matplotlylib\u001b[39m.\u001b[39;49mExporter(renderer)\u001b[39m.\u001b[39;49mrun(fig)\n\u001b[1;32m    113\u001b[0m     \u001b[39mif\u001b[39;00m resize:\n\u001b[1;32m    114\u001b[0m         renderer\u001b[39m.\u001b[39mresize()\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/plotly/matplotlylib/mplexporter/exporter.py:51\u001b[0m, in \u001b[0;36mExporter.run\u001b[0;34m(self, fig)\u001b[0m\n\u001b[1;32m     49\u001b[0m     \u001b[39mimport\u001b[39;00m \u001b[39mmatplotlib\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpyplot\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mplt\u001b[39;00m\n\u001b[1;32m     50\u001b[0m     plt\u001b[39m.\u001b[39mclose(fig)\n\u001b[0;32m---> 51\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcrawl_fig(fig)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/plotly/matplotlylib/mplexporter/exporter.py:118\u001b[0m, in \u001b[0;36mExporter.crawl_fig\u001b[0;34m(self, fig)\u001b[0m\n\u001b[1;32m    115\u001b[0m \u001b[39mwith\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mrenderer\u001b[39m.\u001b[39mdraw_figure(fig\u001b[39m=\u001b[39mfig,\n\u001b[1;32m    116\u001b[0m                                props\u001b[39m=\u001b[39mutils\u001b[39m.\u001b[39mget_figure_properties(fig)):\n\u001b[1;32m    117\u001b[0m     \u001b[39mfor\u001b[39;00m ax \u001b[39min\u001b[39;00m fig\u001b[39m.\u001b[39maxes:\n\u001b[0;32m--> 118\u001b[0m         \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcrawl_ax(ax)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/plotly/matplotlylib/mplexporter/exporter.py:123\u001b[0m, in \u001b[0;36mExporter.crawl_ax\u001b[0;34m(self, ax)\u001b[0m\n\u001b[1;32m    120\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mcrawl_ax\u001b[39m(\u001b[39mself\u001b[39m, ax):\n\u001b[1;32m    121\u001b[0m     \u001b[39m\"\"\"Crawl the axes and process all elements within\"\"\"\u001b[39;00m\n\u001b[1;32m    122\u001b[0m     \u001b[39mwith\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mrenderer\u001b[39m.\u001b[39mdraw_axes(ax\u001b[39m=\u001b[39max,\n\u001b[0;32m--> 123\u001b[0m                                  props\u001b[39m=\u001b[39mutils\u001b[39m.\u001b[39;49mget_axes_properties(ax)):\n\u001b[1;32m    124\u001b[0m         \u001b[39mfor\u001b[39;00m line \u001b[39min\u001b[39;00m ax\u001b[39m.\u001b[39mlines:\n\u001b[1;32m    125\u001b[0m             \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mdraw_line(ax, line)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/plotly/matplotlylib/mplexporter/utils.py:272\u001b[0m, in \u001b[0;36mget_axes_properties\u001b[0;34m(ax)\u001b[0m\n\u001b[1;32m    264\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mget_axes_properties\u001b[39m(ax):\n\u001b[1;32m    265\u001b[0m     props \u001b[39m=\u001b[39m {\u001b[39m'\u001b[39m\u001b[39maxesbg\u001b[39m\u001b[39m'\u001b[39m: export_color(ax\u001b[39m.\u001b[39mpatch\u001b[39m.\u001b[39mget_facecolor()),\n\u001b[1;32m    266\u001b[0m              \u001b[39m'\u001b[39m\u001b[39maxesbgalpha\u001b[39m\u001b[39m'\u001b[39m: ax\u001b[39m.\u001b[39mpatch\u001b[39m.\u001b[39mget_alpha(),\n\u001b[1;32m    267\u001b[0m              \u001b[39m'\u001b[39m\u001b[39mbounds\u001b[39m\u001b[39m'\u001b[39m: ax\u001b[39m.\u001b[39mget_position()\u001b[39m.\u001b[39mbounds,\n\u001b[1;32m    268\u001b[0m              \u001b[39m'\u001b[39m\u001b[39mdynamic\u001b[39m\u001b[39m'\u001b[39m: ax\u001b[39m.\u001b[39mget_navigate(),\n\u001b[1;32m    269\u001b[0m              \u001b[39m'\u001b[39m\u001b[39maxison\u001b[39m\u001b[39m'\u001b[39m: ax\u001b[39m.\u001b[39maxison,\n\u001b[1;32m    270\u001b[0m              \u001b[39m'\u001b[39m\u001b[39mframe_on\u001b[39m\u001b[39m'\u001b[39m: ax\u001b[39m.\u001b[39mget_frame_on(),\n\u001b[1;32m    271\u001b[0m              \u001b[39m'\u001b[39m\u001b[39mpatch_visible\u001b[39m\u001b[39m'\u001b[39m:ax\u001b[39m.\u001b[39mpatch\u001b[39m.\u001b[39mget_visible(),\n\u001b[0;32m--> 272\u001b[0m              \u001b[39m'\u001b[39m\u001b[39maxes\u001b[39m\u001b[39m'\u001b[39m: [get_axis_properties(ax\u001b[39m.\u001b[39;49mxaxis),\n\u001b[1;32m    273\u001b[0m                       get_axis_properties(ax\u001b[39m.\u001b[39myaxis)]}\n\u001b[1;32m    275\u001b[0m     \u001b[39mfor\u001b[39;00m axname \u001b[39min\u001b[39;00m [\u001b[39m'\u001b[39m\u001b[39mx\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39my\u001b[39m\u001b[39m'\u001b[39m]:\n\u001b[1;32m    276\u001b[0m         axis \u001b[39m=\u001b[39m \u001b[39mgetattr\u001b[39m(ax, axname \u001b[39m+\u001b[39m \u001b[39m'\u001b[39m\u001b[39maxis\u001b[39m\u001b[39m'\u001b[39m)\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/plotly/matplotlylib/mplexporter/utils.py:236\u001b[0m, in \u001b[0;36mget_axis_properties\u001b[0;34m(axis)\u001b[0m\n\u001b[1;32m    233\u001b[0m     props[\u001b[39m'\u001b[39m\u001b[39mfontsize\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m    235\u001b[0m \u001b[39m# Get associated grid\u001b[39;00m\n\u001b[0;32m--> 236\u001b[0m props[\u001b[39m'\u001b[39m\u001b[39mgrid\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m get_grid_style(axis)\n\u001b[1;32m    238\u001b[0m \u001b[39m# get axis visibility\u001b[39;00m\n\u001b[1;32m    239\u001b[0m props[\u001b[39m'\u001b[39m\u001b[39mvisible\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m axis\u001b[39m.\u001b[39mget_visible()\n\nFile \u001b[0;32m~/anaconda3/envs/cyberhawk_ai/lib/python3.10/site-packages/plotly/matplotlylib/mplexporter/utils.py:246\u001b[0m, in \u001b[0;36mget_grid_style\u001b[0;34m(axis)\u001b[0m\n\u001b[1;32m    244\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mget_grid_style\u001b[39m(axis):\n\u001b[1;32m    245\u001b[0m     gridlines \u001b[39m=\u001b[39m axis\u001b[39m.\u001b[39mget_gridlines()\n\u001b[0;32m--> 246\u001b[0m     \u001b[39mif\u001b[39;00m axis\u001b[39m.\u001b[39;49m_gridOnMajor \u001b[39mand\u001b[39;00m \u001b[39mlen\u001b[39m(gridlines) \u001b[39m>\u001b[39m \u001b[39m0\u001b[39m:\n\u001b[1;32m    247\u001b[0m         color \u001b[39m=\u001b[39m export_color(gridlines[\u001b[39m0\u001b[39m]\u001b[39m.\u001b[39mget_color())\n\u001b[1;32m    248\u001b[0m         alpha \u001b[39m=\u001b[39m gridlines[\u001b[39m0\u001b[39m]\u001b[39m.\u001b[39mget_alpha()\n\n\u001b[0;31mAttributeError\u001b[0m: 'XAxis' object has no attribute '_gridOnMajor'"
}

Any suggestions are welcomed,
Thanks :slight_smile:

Hi Kostas!

Very Strange, using your code on my machine, I don’t get the same error.

Are you running this in google collab?
Also just to double check is this the exact code you are using?
Also, also, can you see if you are running into the exact same issue if wandb is disabled/commented out?

Cheers,
Artsiom

Hi Artsiom,
I’m running on my local environment.
Yes, that’s the exact code that I’m using.
I’ve tried without Wandb and it works fine.

I’ve also tried today the same code with Wandb and works as expected :S , very weird …

Thanks,
Kostas

Hi Kostas,

That is very strange :0
But now that it works fine, you are not seeing any errors that are popping up anymore?

Cheers!
Artsiom

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.