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

765
Views
Plt.Scatter: cómo agregar título y xlabel e ylabel

¿Hay alguna forma de agregar título (y xlabel e ylabel) a plt.scatter(x,y,...) o plt.plot(x,y,...) directamente sin escribir líneas adicionales?

Es fácil agregarlo cuando usamos Series_name.plot en el que simplemente escribimos Series_name.plot(...,title='name') pero no me funciona si escribo: plt.scatter(..., título='nombre') o plt.plot(...,título='nombre')

[plt<< importar matplotlib.pyplot como plt]

Estoy usando Phyton 3.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

De la documentación de plt.scatter() no hay tales argumentos para establecer el título o las etiquetas.

Pero tampoco el comando plt.plot() tiene tales argumentos. plt.plot(x,y, title="title") genera un error AttributeError: Unknown property title . Así que me pregunto por qué esto debería funcionar en cualquier caso.

En cualquier caso, la forma habitual de establecer el título es plt.title . La forma habitual de establecer las etiquetas es plt.xlabel y plt.ylabel .

 import matplotlib.pyplot as plt x= [8,3,5]; y = [3,4,5] plt.scatter(x,y) plt.title("title") plt.xlabel("x-label") plt.ylabel("y-label") plt.show()
over 4 years ago · Santiago Trujillo Report

0

Es tan simple como agregar:

 plt.xlabel('your xlabel') plt.ylabel('your ylabel') plt.title('your title')

después del comando plt.scatter(). Luego, escribe plt.show() para mostrar la imagen con las etiquetas y los títulos. Puede leer más sobre esto aquí: http://matplotlib.org/users/text_intro.html

over 4 years ago · Santiago Trujillo Report

0

No puede agregar título, xlabel, ylabel, etc. sin líneas adicionales, pero puede usar una sola línea adicional si cree que es mejor

 import matplotlib.pyplot as plt plt.scatter([1,2,3,4,5,6],[3,5,3,2,4,7]) plt.gca().update(dict(title='SCATTER', xlabel='x', ylabel='y', ylim=(0,10)))

Este enfoque tiene más sentido si desea aplicar los mismos atributos a un grupo de parcelas, porque puede preparar de antemano un diccionario para establecer todos los parámetros que desea aplicar a cada parcela.

ingrese la descripción de la imagen aquí

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!