Setting tick colors of matplotlib 3D plot

前端 未结 2 1052
野性不改
野性不改 2021-01-18 15:44

If I have a 3D matplotlib plot (Axes3D object), how do I change the color of the tick marks? I figured out how to change the color of the axis line, the tick la

2条回答
  •  不思量自难忘°
    2021-01-18 16:27

    As mentioned in manual page about tick_params(axis='both', **kwargs) you get a bug:

    While this function is currently implemented, the core part of the Axes3D object may ignore some of these settings. Future releases will fix this. Priority will be given to those who file bugs.

    To override this problem use inner _axinfo dictionary as in this example:

    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib import pyplot as plt
    
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    
    ax.scatter((0, 0, 1), (0, 1, 0), (1, 0, 0))
    
    ax.xaxis._axinfo['tick']['color']='r'
    ax.yaxis._axinfo['tick']['color']='r'
    ax.zaxis._axinfo['tick']['color']='r'
    plt.show()
    

提交回复
热议问题