LoginSignup
5
1

More than 3 years have passed since last update.

Google Colabでplotlyの ```TypeError: imshow() got an unexpected keyword argument 'labels'``` エラー

Last updated at Posted at 2020-12-09

Google ColabでTypeError: imshow() got an unexpected keyword argument 'labels'エラー

TL;DR

# plotlyをアップグレードして, Google Colabのランタイムを再起動(出荷状態に戻すとバージョンがまた元に戻るので注意)
!pip install --upgrade plotly

問題

  • Google Colabで, plotlyでヒートマップなどを表示しようとして, 軸ラベルを付与しようとしたら TypeError: imshow() got an unexpected keyword argument 'labels' と怒られてしまった.
data=[[1, 25, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, 5, 20]]
fig = px.imshow(data,
                labels=dict(x="Day of Week", y="Time of Day", color="Productivity"),
                x=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
                y=['Morning', 'Afternoon', 'Evening']
               )
fig.update_xaxes(side="top")
fig.show()

image.png

原因

対策

  • plotlyのバージョンをアップグレードして, Google Colabのランタイムを再起動する.
  • その後, 4.14.0になりlabelsが利用できるようになる.
import plotly
print(plotly.__version__)

image.png

image.png

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1