sK500:
私は、関心の次の列が含まれているパンダのデータフレームを持っています。
['Relative Width', 'Relative Height', 'Object Name', 'Object ID']
で決定15色で15人のオブジェクト名がありdf.plot(c='Object ID')
、その農産物次の図は:
私はこれを行う方法を、15オブジェクト名と凡例を表示したいですか?
import matplotlib.pyplot as plt
from annotation_parsers import parse_voc_folder
def visualize_box_relative_sizes(folder_path, voc_conf, cache_file='data_set_labels.csv'):
frame = parse_voc_folder(folder_path, voc_conf, cache_file)
title = f'Relative width and height for {frame.shape[0]} boxes.'
frame.plot(
kind='scatter',
x='Relative Width',
y='Relative Height',
title=title,
c='Object ID',
colormap='gist_rainbow',
colorbar=False,
)
plt.show()
wwnde勧告に基づいて、私は次のようにコードを変更しました:
def visualize_box_relative_sizes(folder_path, voc_conf, cache_file='data_set_labels.csv'):
frame = parse_voc_folder(folder_path, voc_conf, cache_file)
title = f'Relative width and height for {frame.shape[0]} boxes.'
sns.scatterplot(x=frame["Relative Width"], y=frame["Relative Height"], hue=frame["Object Name"])
plt.title(title)
plt.show()
これは次のような結果を生成します。
wwnde:
してみてください
fig, ax = plt.subplots()
ax = sns.scatterplot(x="total_bill", y="tip",
hue="size", size="size",
data=tips)
ax.set_title('title')
plt.show()
これは、あなたのデフォルトの色の伝説を与える必要があります