user4369032
user4369032

Reputation:

How to create square log-log plots in matplotlib?

I am trying to create square plots (equal axes length) on log-log scale, but I have no luck. Can any one help me with this.

Upvotes: 1

Views: 529

Answers (1)

Nimal Naser
Nimal Naser

Reputation: 458

You can use this function:

def set_aspect_ratio_log(plot, aspect_ratio):
        x_min, x_max = plot.get_xlim()
        y_min, y_max = plot.get_ylim()
        return plot.set_aspect(aspect_ratio * ((math.log10(x_max / x_min)) / (math.log10(y_max / y_min))))

Hope this helps.

Upvotes: 1

Related Questions