변수 플롯 산포도에 대한하기 matplotlib 문자열

요점

산포도를 그릴 때, 일반적으로 가변 입력 데이터에 대한 담체로서 사용된다.
사실, 문자열 입력 데이터 저장 매체로서 사용될 수있다.

다음 코드 data = {“a”: x, “b”: y, “color”: c, “size”: s}의 크기에 대한 산포도 데이터 표시 색상에 입력되는 데이터 딕셔너리 키에 대응하는 키 - 값 쌍으로서 데이터 캐릭터 스트링이다.

하기 matplotlib 프로그래밍

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.gca()

x = np.random.rand(50)*10
y = np.random.rand(50)*10+20
s = np.random.rand(50)*100
c = np.random.rand(50)

data = {"a": x, "b": y, "color": c, "size": s}

# with the "data" keyboard argument
ax.scatter("a", "b", c="color", s="size", data=data)

ax.set(xlabel="X", ylabel="Y")

plt.show()

완료지도

그림 삽입 설명 여기

게시 된 515 개 원래 기사 · 원 찬양 1014 ·은 210,000 + 조회수

추천

출처blog.csdn.net/weixin_43896318/article/details/104335581