मुझे एक ही समस्या है here प्रस्तुत किया गया है, हालांकि प्रस्तावित समाधान मेरे लिए काम नहीं करता है।स्कैटर प्लॉट के लिए एक्सिस सीमाएं - Matplotlib
मैं डेटा का एक सेट जो मुख्य कथानक इस पद्धति है साजिश रचने हूँ:
कौन सा एक साजिश जो अक्ष सीमा (-1, 1) दोनों x और y में से भिन्न होता है है, एक मार्जिन कोड के इस टुकड़े के साथ सेट के साथ:
plt.figure()
plt.show(data)
## Add some margin
l, r, b, t = plt.axis()
dx, dy = r-l, t-b
plt.axis([l-0.1*dx, r+0.1*dx, b-0.1*dy, t+0.1*dy])
समस्या 'है क्योंकि मैं अधिक "जटिल" साजिश, जिसमें करने के लिए मुझे बनाया कुछ परिवर्तन किया था की है।
def plot_quiver_singularities(min_points, max_points, vector_field_x, vector_field_y, file_path):
"""
Plot the singularities of vector field
:param file_path : the path to save the data
:param vector_field_x : the vector field x component to be plot
:param vector_field_y : the vector field y component to be plot
:param min_points : a set (x, y) of min points field
:param max_points : a set (x, y) of max points field
"""
fig = plt.figure(figsize=(8, 8))
ax = fig.add_axes([.13, .3, .6, .6])
## Plot quiver
x, y = numpy.mgrid[-1:1:100*1j, -1:1:100*1j]
m = numpy.sqrt(numpy.power(vector_field_x, 2) + numpy.power(vector_field_y, 2))
quiver = ax.quiver(x, y, vector_field_x, vector_field_y, m, zorder=1)
## Plot critical points
x = numpy.linspace(-1, 1, x_steps)
y = numpy.linspace(-1, 1, y_steps)
# Draw the min points
x_indices = numpy.nonzero(min_points)[0]
y_indices = numpy.nonzero(min_points)[1]
ax.scatter(x[x_indices], y[y_indices], marker='$\\circlearrowright$', s=100, zorder=2)
# Draw the max points
x_indices = numpy.nonzero(max_points)[0]
y_indices = numpy.nonzero(max_points)[1]
ax.scatter(x[x_indices], y[y_indices], marker='$\\circlearrowleft$', s=100, zorder=2)
## Put legends
marker_min = plt.Line2D((0, 0), (0, 0), markeredgecolor=(1.0, 0.4, 0.0), linestyle='',
marker='$\\circlearrowright$', markeredgewidth=1, markersize=10)
marker_max = plt.Line2D((0, 0), (0, 0), markeredgecolor=(0.2, 0.2, 1.0), linestyle='',
marker='$\\circlearrowleft$', markeredgewidth=1, markersize=10)
plt.legend([marker_min, marker_max], ['CW rot. center', 'CCW rot. center'], numpoints=1,
loc='center left', bbox_to_anchor=(1, 0.5))
quiver_cax = fig.add_axes([.13, .2, .6, .03])
fig.colorbar(quiver, orientation='horizontal', cax=quiver_cax)
## Set axis limits
plt.xlim(-1, 1)
plt.ylim(-1, 1)
## Add some margin
# l, r, b, t = plt.axis()
# dx, dy = r-l, t-b
# plt.axis([l-0.1*dx, r+0.1*dx, b-0.1*dy, t+0.1*dy])
plt.savefig(file_path + '.png', dpi=dpi)
plt.close()
यह निम्न छवि बनाता है:
के रूप में देखा जा सकता है, अक्ष सीमा पकड़ नहीं है और मैं क्यों अभी तक नहीं मिला था इस कोड है कि यह उत्पादन होता है।
किसी भी मदद की सराहना की जाएगी।
अग्रिम धन्यवाद।
यहां थोड़ा अनिश्चित है, क्या ऑर्डर एक भूमिका निभाता है? आपने अंतिम अक्ष कमांड के बाद कलर बार लगाया है। इसे हटाने की कोशिश करने के लिए देखभाल? – Dan
हां, मैंने ऐसा करने की कोशिश की। नतीजा वही है। समस्या तब होती है जब मैं स्कैटर फ़ंक्शन को कॉल करता हूं। – pceccon
ऑटोस्केलिंग बंद करें या स्कैटर को कॉल करने के बाद आप जो चाहते हैं उसे सीमाएं फिर से सेट करें। – tacaswell