0

im trying to plot 2 different plot, one at the left of the other, i try to use sublot from matplot but it is putting the seccond plot down the other i supose i use it wrong the subplot, this is my code

# Create bars

from matplotlib.pyplot import figure
bar = plt.figure(figsize=(10,5))
plt.subplot(121)
plt.barh(plottl['Nombres'] ,plottl['Probas'])
presunto= plt.figure(figsize=(10,10))
presunto = plt.subplot(122)
img=mpimg.imread((predict+names[0]+ '/'+ onlyfiles[0]))
mgplot = plt.imshow(img)

plt.show()
predictions=[]

now here is a pic. of what is happening

enter image description here

i was hopping you can helpme to solve this, thank you all in advance

edit: i put here the asked picture

enter image description here

mimus
  • 367
  • 4
  • 21

2 Answers2

1

You are creating 2 figures, instead of one with 2 subplots. remove the line presunto= plt.figure(figsize=(10,10)) and it should work.

Diziet Asahi
  • 38,379
  • 7
  • 60
  • 75
0

You are creating 2 figures instead of 2 subplots, although it's better to use gridspec when you want to draw subplots with different sizes. look at this link

from matplotlib.pyplot import figure
bar = plt.figure(figsize=(10,5))
plt.subplot(121)
plt.barh(plottl['Nombres'] ,plottl['Probas'])

presunto = plt.subplot(122)
img=mpimg.imread((predict+names[0]+ '/'+ onlyfiles[0]))
mgplot = plt.imshow(img,aspect="auto")

plt.show()
Mohsen_Fatemi
  • 2,183
  • 2
  • 16
  • 25