Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
¿Cómo establecer límites para la línea espinal con axisartist?

¿Cómo puedo establecer los límites de axisartist.axis[].line ?

Con la API normal, es posible establecer los límites de la columna del eje con:

 ax.spines['right'].set_bounds(low=0.01,high=0.1)

Pero axisartist no tiene un objeto de spines . En cambio, las líneas espinales se implementan con ax.axis['left'].line , que no tiene un método get_bounds y set_bounds .

Ejemplo:

 import numpy as np import matplotlib.pyplot as plt import mpl_toolkits.axisartist as axisartist import seaborn as sns use_artist = True x = np.random.random(10) y = np.random.random(10) x.sort() y.sort() if use_artist: fig = plt.figure() ax = fig.add_subplot(axes_class=axisartist.Axes) else: fig, ax = plt.subplots() ax.scatter(x, y, marker="o") if use_artist: ax.axis['right'].set_visible(False) ax.axis['top'].set_visible(False) # HOW TO SET BOUNDS OF ax.axis['left'].line here? else: sns.despine() ax.spines['left'].set_bounds(ax.get_yticks()[1], ax.get_yticks()[-2]) ax.spines['bottom'].set_bounds(ax.get_xticks()[1], ax.get_xticks()[-2]) plt.tight_layout() plt.draw() plt.show()

Aquí hay ejemplos sin y con axisartist :

Ejemplo con API normal Ejemplo con axisartist

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use axes.set_xbounds() o axes.set_xlim() (los documentos se encuentran aquí y aquí respectivamente). Ambos métodos parecen tener una función idéntica, pero set_xlim tiene más funciones, en caso de que las necesite. Entonces, su nuevo código modificado que usa solo axisartist es:

 import numpy as np import matplotlib.pyplot as plt import mpl_toolkits.axisartist as axisartist # Data x = np.random.random(10) y = np.random.random(10) x.sort() y.sort() # Creating figure, plot fig = plt.figure() ax = fig.add_subplot(axes_class=axisartist.Axes) ax.scatter(x, y, marker="o") # Formatting axes ax.axis['right'].set_visible(False) ax.axis['top'].set_visible(False) ax.axis['left'].major_ticklabels.set_pad(10) ax.axis['bottom'].major_ticklabels.set_pad(10) # Setting axis limits ax.set_xlim(left=0.2, right = 0.5) ax.set_ylim(bottom=0, top = 0.7) plt.tight_layout() plt.draw() plt.show()
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!