【问题标题】:How to change axes labels to multiples of pi [duplicate]如何将轴标签更改为 pi 的倍数 [重复]
【发布时间】:2020-10-27 11:28:59
【问题描述】:

我正在显示已转换为极坐标的数据点的分布,并正在使用直方图显示点的分布。如何将 x 轴更改为 pi 的倍数?

import numpy as np
import matplotlib.pyplot as plt


Phi_coords = []

# Extracting phi values from polars
for i in range(len(test_polars)):
    Phi_coords.append(test_polars[i][1])

    
# matplotlib histogram
plt.hist(Phi_coords, color = 'blue', edgecolor = 'black', bins = 360)


# Add labels
plt.title('Distribution')
plt.xlabel('Phi Coordinate')
plt.ylabel('Number at Phi Coordinate')

【问题讨论】:

    标签: python matplotlib graphing


    【解决方案1】:

    需要补充:

    pi = np.pi
    
    plt.xticks(np.arange(-pi, pi+pi/2, step=(pi/2)), ['-π','-π/2','0','π/2','π'])
    

    【讨论】:

    • 您在 30 秒内找到了解决您自己问题的方法?快速学习者。
    猜你喜欢
    • 1970-01-01
    • 2021-11-25
    • 2020-03-29
    • 1970-01-01
    • 2020-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-28
    相关资源
    最近更新 更多