“Atur Axis Ticks Matplotlib” Kode Jawaban

Atur Axis Ticks Matplotlib

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

x = [0,5,9,10,15]
y = [0,1,2,3,4]
fig, ax = plt.subplots()
ax.plot(x,y)
start, end = ax.get_xlim()
ax.set_xticks(np.arange(start, end, 2))
plt.show()
HotFlow

Mengubah jumlah kutu pada sumbu plot matplotlib

# Get the current axis
ax = plt.gca()

# Only label every 20 th value
ticks_to_use = df.index[::20]

# Set format of labels(note year not excluded as requested)
labels = [i.strftime("%-H:%M") for i in ticks_to_use]

# Now set the ticks and labels
ax.set_xticks(ticks_to_use)
ax.set_xticklabels(labels)
Witty Worm

Tingkatkan Axis Ticks Pyplot

x = [0,5,9,10,16]
y = [0,1,2,3,5]

x_ticks = np.arange(0, 16, 5)
plt.xticks(x_ticks)

y_ticks = np.arange(0, 5, 2)
plt.yticks(y_ticks)

plt.plot(x, y)
Dead Dotterel

Jawaban yang mirip dengan “Atur Axis Ticks Matplotlib”

Pertanyaan yang mirip dengan “Atur Axis Ticks Matplotlib”

Lebih banyak jawaban terkait untuk “Atur Axis Ticks Matplotlib” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya