pythonfigurefigsizeupsetplot

Changing the figsize in the upsetplot module


How I can change the figsize in the upsetplot module in Python? I see that there is a fig parameter, but I don't get how to assign a new figure with a predefined size to it.


Solution

  • You can use matplotlib to define a figure, and then pass it to upsetplot. However, the figure size is reset automatically by upsetplot unless element_size=None is set.

    So please use something like:

    from matplotlib import pyplot as plt
    from upsetplot import generate_counts, plot
    
    example = generate_counts()
    fig = plt.figure(figsize=(10, 3))
    plot(example, fig=fig, element_size=None)
    plt.show()
    

    Thanks for inspiring the development of an example on this topic: Customising element size and figure size