Adjusting gridlines on a 3D Matplotlib figure

前端 未结 4 2202
感动是毒
感动是毒 2021-02-15 03:05

I\'m getting ready for a presentation and I have some example figures of 3D matplotlib figures. However, the gridlines are too light to see on the projected images.

4条回答
  •  余生分开走
    2021-02-15 04:10

    Just use this to change the linewidth:

    plt.rcParams['grid.linewidth'] = 2
    

    Full scripts to plot the figure:

    import numpy as np
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D 
    
    points = (5*np.random.randn(3, 50)+np.tile(np.arange(1,51), (3, 1))).transpose()
    fig = plt.figure(figsize = (10,10))
    ax = fig.add_subplot(111, projection='3d') 
    ax.scatter(points[:,0], points[:,1], points[:,2])
    #ax.view_init(elev=0., azim=0)
    ax.set_ylim([0, 60])
    ax.set_zlim([0, 60])
    ax.set_xlim([0, 60])
    ax.set_zlabel('Cytokine')
    ax.set_ylabel('Parameter')
    plt.rcParams['grid.linewidth'] = 4   # change linwidth
    plt.rcParams['grid.color'] = "black" # change color
    

提交回复
热议问题