Adjusting gridlines on a 3D Matplotlib figure

前端 未结 4 2201
感动是毒
感动是毒 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 03:48

    If you don't mind having all the lines thicker then you could adjust the default rc settings.

    Given a graph such as:

    enter image description here

    We can add:

    import matplotlib as mpl
    mpl.rcParams['lines.linewidth'] = 2
    

    To increase the default line width of all lines, giving a result of:

    enter image description here

    Alternatively, if you feel this looks ugly, you could use:

    ax.w_xaxis.gridlines.set_lw(3.0)
    ax.w_yaxis.gridlines.set_lw(3.0)
    ax.w_zaxis.gridlines.set_lw(3.0)
    

    to adjust the line width of each axis to 3.0, producing:

    enter image description here

    In order to update the colour, so the grid-lines really pop, you could add:

    ax.w_xaxis._axinfo.update({'grid' : {'color': (0, 0, 0, 1)}})
    ax.w_yaxis._axinfo.update({'grid' : {'color': (0, 0, 0, 1)}})
    ax.w_zaxis._axinfo.update({'grid' : {'color': (0, 0, 0, 1)}})
    

    Which produces:

    enter image description here

    The methods are pretty hacky, but as far as I am aware there is no simpler way of achieving these results!! Hope this helps; let me know if you require any further assistance!

提交回复
热议问题