Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
750 views
in Technique[技术] by (71.8m points)

python matplotlib: way to transpose axes

Suppose I have a plotting function that takes an axes argument (or returns one). Is there some low-level method for transposing the whole plot so that the x-axis becomes the y-axis and vice-versa? Or even the axes before the plot so that the plotting function just does everything correctly (labeling) by relying on the axes functions?

I know how to do this "manually", but I'm wondering if there is a slightly hidden level of abstraction that allows this kind of transformation.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

An old post (circa 2005) to the mailing list from John Hunter. I suspect that this a rare enough of a desire and tricky enough to do that it has not been added sense then.

John Hunter's example for swapping axes on an existing plot was

line2d = plot(rand(10))[0]

def swap(xdata, ydata):
    line2d.set_xdata(ydata)
    line2d.set_ydata(xdata)
    draw()

swap(line2d.get_xdata(), line2d.get_ydata())

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...