Skip to content

Instantly share code, notes, and snippets.

@ialexpovad
Created December 20, 2021 11:33
Show Gist options
  • Save ialexpovad/c55d11c7dcfb0d5eb5d6270c6bb278de to your computer and use it in GitHub Desktop.
Save ialexpovad/c55d11c7dcfb0d5eb5d6270c6bb278de to your computer and use it in GitHub Desktop.
[DivisionAxes.py] Деление осей и подписи к ним #python #matplolib
import numpy as np
import matplotlib.pyplot as plt
# Подключаем модуль управления тиками:
import matplotlib.ticker as ticker
x = np.linspace(-10, 10, 200)
y = 0.01*(x + 9)*(x + 6)*(x - 6)*(x - 9)*x
fig, ax = plt.subplots()
ax.plot(x, y, color = 'r', linewidth = 3)
# Устанавливаем интервал основных делений:
ax.xaxis.set_major_locator(ticker.MultipleLocator(2))
# Устанавливаем интервал вспомогательных делений:
ax.xaxis.set_minor_locator(ticker.MultipleLocator(1))
# Тоже самое проделываем с делениями на оси "y":
ax.yaxis.set_major_locator(ticker.MultipleLocator(50))
ax.yaxis.set_minor_locator(ticker.MultipleLocator(10))
fig.set_figwidth(12)
fig.set_figheight(8)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment