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

393
Views
Matplotlib cómo cambiar figsize para matshow

¿Cómo cambiar figsize para matshow () en el cuaderno jupyter?

Por ejemplo, este código cambia el tamaño de la figura.

 %matplotlib inline import matplotlib.pyplot as plt import pandas as pd d = pd.DataFrame({'one' : [1, 2, 3, 4, 5], 'two' : [4, 3, 2, 1, 5]}) plt.figure(figsize=(10,5)) plt.plot(d.one, d.two)

Pero el código de abajo no funciona

 %matplotlib inline import matplotlib.pyplot as plt import pandas as pd d = pd.DataFrame({'one' : [1, 2, 3, 4, 5], 'two' : [4, 3, 2, 1, 5]}) plt.figure(figsize=(10,5)) plt.matshow(d.corr())
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

De forma predeterminada, plt.matshow() produce su propia figura, por lo que, en combinación con plt.figure() , se crearán dos figuras y la que alberga el diagrama matshow no es la que tiene el conjunto figsize.

Hay dos opciones:

  1. Usa el argumento fignum

     plt.figure(figsize=(10,5)) plt.matshow(d.corr(), fignum=1)
  2. Trace el matshow usando matplotlib.axes.Axes.matshow en lugar de pyplot.matshow .

     fig, ax = plt.subplots(figsize=(10,5)) ax.matshow(d.corr())
over 4 years ago · Santiago Trujillo Report

0

Las soluciones no me funcionaron pero encontré otra forma:

 plt.figure(figsize=(10,5)) plt.matshow(d.corr(), fignum=1, aspect='auto')
over 4 years ago · Santiago Trujillo Report

0

Mejorando la solución de @ImportanceOfBeingErnest,

 matfig = plt.figure(figsize=(8,8)) plt.matshow(d.corr(), fignum=matfig.number)

De esta manera, no necesita realizar un seguimiento de los números de figura.

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!