Matplotlib.axis.axis.remove_overlapping_locs() - 修剪与主要股票代码位置重叠的次要股票代码位置

Matplotlib.axis.axis.remove_overlapping_locs()

matplotlib库的Axis模块中的Axis.remove_overlapping_locs函数用于修剪与主要股票代码位置重叠的次要股票代码位置。

语法:Axis.remove_overlapping_locs

参数:该方法接受以下参数。

  • formatter:该参数是 定位器 .

返回值:该方法不返回任何值。

下面的例子说明了matplotlib.axis.axis.remove_overlapping_locs函数在matplotlib.axis中的作用:

示例1

# Implementation of matplotlib function 
from matplotlib.axis import Axis
import matplotlib.pyplot as plt 
from matplotlib.ticker import MultipleLocator, ScalarFormatter 
     
fig, ax = plt.subplots() 
ax.plot([0, 5, 10, 15, 20], [3, 2, 1, 2, 4]) 
     
Axis.set_minor_locator(ax.xaxis, MultipleLocator(1)) 
Axis.set_minor_formatter(ax.xaxis, ScalarFormatter())
Axis.set_major_locator(ax.xaxis, MultipleLocator(4)) 
     
ax.tick_params(axis ='both', which ='major',  
               labelsize = 14, pad = 12,  
               colors ='g') 
     
ax.tick_params(axis ='both', which ='minor', 
               labelsize = 8, colors ='b')
ax.xaxis.remove_overlapping_locs
    
plt.title("Matplotlib.axis.Axis.remove_overlapping_locs \
Example", fontsize = 12, fontweight ='bold') 
  
plt.show()

输出:

Matplotlib.axis.axis.remove_overlapping_locs()

示例2

# Implementation of matplotlib function 
from matplotlib.axis import Axis
import matplotlib.pyplot as plt 
import matplotlib.ticker as ticker
from matplotlib.ticker import MultipleLocator, ScalarFormatter
     
     
x = [0, 5, 9, 10, 15] 
y = [0, 1, 2, 3, 4] 
     
tick_spacing = 1
     
fig, ax = plt.subplots(1, 1) 
ax.plot(x, y)
  
Axis.set_major_locator(ax.xaxis, 
                       ticker.MultipleLocator(3))
Axis.set_minor_locator(ax.xaxis, 
                       ticker.MultipleLocator(tick_spacing))
Axis.set_minor_formatter(ax.xaxis, ScalarFormatter())
ax.xaxis.remove_overlapping_locs
    
plt.title("Matplotlib.axis.Axis.remove_overlapping_locs \
Example", fontsize = 12, fontweight ='bold') 
  
plt.show()

输出:

Matplotlib.axis.axis.remove_overlapping_locs()

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程