Matplotlib Izgara Çizgileri Ekleme
Bir Grafiğe Izgara Çizgileri Ekleme
Pyplot ile, grid()
arsaya ızgara çizgileri eklemek için işlevi kullanabilirsiniz.
Örnek
Grafiğe ızgara çizgileri ekleyin:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([80,
85, 90, 95, 100, 105, 110, 115, 120, 125])
y = np.array([240, 250, 260,
270, 280, 290, 300, 310, 320, 330])
plt.title("Sports Watch Data")
plt.xlabel("Average Pulse")
plt.ylabel("Calorie Burnage")
plt.plot(x,
y)
plt.grid()
plt.show()
Sonuç:
Hangi Izgara Çizgilerinin Görüntüleneceğini Belirtin
Hangi ızgara çizgilerinin görüntüleneceğini belirlemek axis
için fonksiyondaki parametreyi kullanabilirsiniz .grid()
Yasal değerler: 'x', 'y' ve 'her ikisi'dir. Varsayılan değer 'her ikisi'dir.
Örnek
Yalnızca x ekseni için kılavuz çizgilerini görüntüle:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([80,
85, 90, 95, 100, 105, 110, 115, 120, 125])
y = np.array([240, 250, 260,
270, 280, 290, 300, 310, 320, 330])
plt.title("Sports Watch Data")
plt.xlabel("Average Pulse")
plt.ylabel("Calorie Burnage")
plt.plot(x,
y)
plt.grid(axis = 'x')
plt.show()
Sonuç:
Örnek
Yalnızca y ekseni için kılavuz çizgilerini göster:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([80,
85, 90, 95, 100, 105, 110, 115, 120, 125])
y = np.array([240, 250, 260,
270, 280, 290, 300, 310, 320, 330])
plt.title("Sports Watch Data")
plt.xlabel("Average Pulse")
plt.ylabel("Calorie Burnage")
plt.plot(x,
y)
plt.grid(axis = 'y')
plt.show()
Sonuç:
Izgara için Çizgi Özelliklerini Ayarlayın
Ayrıca ızgaranın çizgi özelliklerini şu şekilde ayarlayabilirsiniz: grid(color = ' color ', linestyle = ' linestyle ', linewidth = sayı ).
Örnek
Kılavuzun çizgi özelliklerini ayarlayın:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([80,
85, 90, 95, 100, 105, 110, 115, 120, 125])
y = np.array([240, 250, 260,
270, 280, 290, 300, 310, 320, 330])
plt.title("Sports Watch Data")
plt.xlabel("Average
Pulse")
plt.ylabel("Calorie Burnage")
plt.plot(x,
y)
plt.grid(color = 'green', linestyle = '--', linewidth = 0.5)
plt.show()