Getting the same subplot size using matplotlib imshow and scatter

后端 未结 3 864

I am trying to plot an image (using matplotlib.imshow) and a scatter plot within the same figure. When trying this, the image appears smaller than the scatter p

3条回答
  •  囚心锁ツ
    2020-12-09 03:54

    Here's some code I use:

    fig, axis_array = plt.subplots(1, 2, figsize=(chosen_value, 1.05 * chosen_value / 2),
                                   subplot_kw={'aspect': 1})
    

    I'm explicitly selecting that there will be 2 sub plots in my figure, and that the figure will be chosen_value tall and each subplot will be about half that size wide, and that the subplots will have an aspect ratio of 1 (i.e., they will both be square). The figure size is a specific ratio which forces the spacing.

提交回复
热议问题