축 레이블이 겹치는 것을 방지하기 위해 Facetgrid 산점도의 치수를 변경하는 방법은 무엇입니까?

심란 카울

틱의 겹침을 제거하기 위해 x 및 y 축의 크기를 늘리고 싶습니다. 또한이 컴포넌트 라벨링을 수평으로 회전 할 수 있습니다.

다음은 코드입니다. 이것이 현재 출력입니다

fg = sns.FacetGrid(data=df, hue='Component',aspect=1.61)
_=plt.grid(which='major', color='#cccccc', alpha=0.45)
_=plt.title('testing', family="Arial", fontsize=12)
_=plt.xlabel("x")
_=plt.ylabel("y")

plt.yticks(AV_df.index,AV_df.Affects_version.values)

scale_factor = 0.1
scale_factorx = 5
ymin, ymax = plt.ylim()
fig= plt.figure(figsize=(3,10))

plt.autoscale(enable=True, axis='x', tight=True)
plt.ylim(ymin * scale_factor, ymax * scale_factor)

fg.map(plt.scatter,'ts','Affects_version').add_legend()

트 렌튼 맥키 니

Facetgrid를 사용하여 산점도 그리기

  • Facetgrid에서 산점도를 사용하는 이유는 hue매개 변수 사용을 활성화하기위한 것입니다.scatter
  • 이 데이터에는 10000 개의 행, y 축에 대한 26 개의 고유 한 값 및 26 개의 고유 한 구성 요소가 있습니다.
  • heightaspect매개 변수를 올바르게 설정하는 것이 Figure 크기를 제어하는 ​​핵심입니다.
import pandas as pd
import random
import numpy as np
import string

# create synthetic data
np.random.seed(365)
random.seed(365)
data = {'affects': [random.choice(string.ascii_uppercase) for _ in range(10000)],
        'ts': [np.random.randint(10, 80) for _ in range(10000)],
        'component': [random.choice(string.ascii_lowercase) for _ in range(10000)]}

# create the dataframe
df = pd.DataFrame(data)

# plot
fg = sns.FacetGrid(data=df, hue='component', height=16, aspect=0.8)
fg.map(plt.scatter, 'ts', 'affects').add_legend()

여기에 이미지 설명 입력

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관