क्योंकि वे साजिश क्षेत्र के अंदर खींचे जाते हैं, कई matplotlib भूखंडों में डेटा द्वारा अक्ष टिक्स अस्पष्ट होते हैं। अक्षरों बाहरी से विस्तारित टिकों को आकर्षित करने का एक बेहतर तरीका है, जैसा कि ggplot
, आर की साजिश प्रणाली में डिफ़ॉल्ट है।matplotlib में, आप आर-स्टाइल अक्ष टिक्स कैसे आकर्षित करते हैं जो धुरी से बाहर की ओर इंगित करते हैं?
सिद्धांत रूप में, इस x- अक्ष और y- अक्ष के लिए TICKDOWN
और TICKLEFT
लाइन शैलियों के साथ टिक लाइनों पुनः बनाकर किया जा सकता है क्रमशः टिक्स:
import matplotlib.pyplot as plt
import matplotlib.ticker as mplticker
import matplotlib.lines as mpllines
# Create everything, plot some data stored in `x` and `y`
fig = plt.figure()
ax = fig.gca()
plt.plot(x, y)
# Set position and labels of major and minor ticks on the y-axis
# Ignore the details: the point is that there are both major and minor ticks
ax.yaxis.set_major_locator(mplticker.MultipleLocator(1.0))
ax.yaxis.set_minor_locator(mplticker.MultipleLocator(0.5))
ax.xaxis.set_major_locator(mplticker.MultipleLocator(1.0))
ax.xaxis.set_minor_locator(mplticker.MultipleLocator(0.5))
# Try to set the tick markers to extend outward from the axes, R-style
for line in ax.get_xticklines():
line.set_marker(mpllines.TICKDOWN)
for line in ax.get_yticklines():
line.set_marker(mpllines.TICKLEFT)
# In real life, we would now move the tick labels farther from the axes so our
# outward-facing ticks don't cover them up
plt.show()
लेकिन व्यवहार में, कि केवल आधा है समाधान क्योंकि get_xticklines
और get_yticklines
विधियां केवल प्रमुख टिक लाइनें लौटती हैं। मामूली टिक अंदर की तरफ इशारा करते रहते हैं।
नाबालिग टिकों के लिए काम क्या है?
यह ऐसा करेगा। धन्यवाद। – pash