1

I have the following plot, however it prints extremely narrowly with wide margins.

names = ['VCI', 'FRI', 'QII', 'VSI', 'WMI', 'PSI', 'GAI', 'CPI', 'FSIQ']
values = [102, 129, 129, 160, 149, 128, 134, 120, 118]

plt.subplot(132)

for x in range(len(values)):
   plt.scatter(names[x], values[x], marker = "$"+str(values[x])+"$", color = "black", s=300)

plt.plot(values[:6], color = 'black', linestyle = 'dashed')

plt.yticks(ticks=[40,50,60,70,80,90,100,110,120,130,140,150,160,170,180])
plt.minorticks_on()
plt.tick_params(axis='x', which='minor', bottom=False)

plt.show()

I tried using the following code, and while the plot itself was a usable size, the margins are way way too wide.

plt.figure(figsize=(20, 5))

What can I do to make the plot readable with narrow/no margins.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158

1 Answers1

0

Option 1: Change plt.subplot(132) to plt.subplot(111). What plt.subplot(132) means is that you want subplots in 1 row with 3 columns and you will be plotting in the 2nd subplot. Since you only want one plot, 111 means 1 row and 1 column and you will be plotting in the first subplot (the only subplot).

Option 2: You can remove the plt.subplot(132) line entirely if this is the only plot you are making, since plt.scatter will create a figure if none exists. If you have other plots being created in the code, you can change the line to plt.figure() to make a new figure that plt.scatter (and the other plotting commands) will use.

jared
  • 4,165
  • 1
  • 8
  • 31