LoginSignup
0
1

More than 5 years have passed since last update.

databricks cloud上でmatplotlibとかseabornのグラフを表示するスニペット

Posted at

コード

こんな感じで plt.subplots() を使うと上手く可視化できる。

import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt

df = pd.DataFrame(np.arange(10).reshape(5,2)) # 元データを適当に作る

fig, ax = plt.subplots()
ax = sns.heatmap(df) # axにグラフオブジェクトを渡す(matplotlibでも一緒)
display(fig) # figの方をdisplayに渡す

# こんな感じに書いてもnotebook上にグラフは表示されない
sns.heatmap(df)
plt.show()

参考

Matplotlib and ggplot in Python Notebooks

0
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
0
1