Matplotlib yaxis线

时间:2015-09-26 22:54:16

标签: python python-2.7 matplotlib

我一直在修补.grid()中的 matplotlib 功能,尝试在 y 中加入一行 - 图形栏的轴 -

但是我没有得到我想要的东西,那就是在y - 轴上只有线条,而且条形图中没有显示这些线条(现在我正在进入y轴和x轴都可以看到条形图中的线条。

对于MWE我正在调用此函数,其中 comp 是一个整数列表的列表,我正在其中运行, args 只是xlabels的名称, ctype len( comp ) filename {{ 1}} 只是用来命名内容的字符串。

title

任何帮助都将不胜感激。

还是这样: enter image description here

1 个答案:

答案 0 :(得分:1)

.grid()来电签名:

  grid( self,
           b     = None,
           which = 'major',
           axis  = 'both',
           **kwargs
           )

Sets the axes grids on or off;

( b ) is a boolean.  ( For MATLAB compatibility, also may be a string {'on'|'off'} )

                  If b == None and ( len(kwargs) == 0 ), toggle the grid state.

                  If **kwargs are supplied, it is assumed
                                            that you want a grid
                                            and b is thus set to True.

( which ) can be 'major' (default),
                 'minor', or
                 'both' to control whether major tick grids,
                                           minor tick grids,
                                           or both are affected.

( axis )  can be 'both' (default),
                 'x', or
                 'y' to control which set of gridlines are drawn.

( **kwargs ) are used to set the grid line properties, eg:

                 ax.grid( color     = 'r',
                          linestyle = '-',
                          linewidth = 2
                          )

解决方案:

ax.grid( ...,  axis = 'y', ... ) #  consider modifying ( zorder ) in case other visual ordering is expected