Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code for Figure 2.3 from the book doesn't match the image (Chapter 2, pages 22-23) #65

Closed
labdmitriy opened this issue Jul 12, 2022 · 1 comment · Fixed by #69
Closed

Comments

@labdmitriy
Copy link
Contributor

labdmitriy commented Jul 12, 2022

Hi @rougier,

If we use the code for the Figure 2.3 from the book, then the border will be inside data coordinates, not outside as expected, and with different tick labels (specifying the code from the book before resolving #63):

fig = plt.figure(figsize=(5, 5), dpi=100)
ax = fig.add_subplot(1, 1, 1, projection='polar')

FC_to_DC = ax.transData.inverted().transform
NDC_to_FC = ax.transAxes.transform
NDC_to_DC = lambda x: FC_to_DC(NDC_to_FC(x))

P = NDC_to_DC([[0,0], [1,0], [1,1], [0,1], [0,0]])

plt.plot(P[:,0], P[:,1], clip_on=False, zorder=-10
         color="k", linewidth=1.0, linestyle="--", )
plt.scatter(P[:-1,0], P[:-1,1],
            clip_on=False, facecolor="w", edgecolor="k")
plt.show()

But the code in Python file is correct.
I compared the code and find that for displaying the figure there are 2 additional lines in Python file:

ax.set_ylim(-1, 1), ax.set_yticks([-1, -0.5, 0, 0.5, 1])

And the first line (setting the limits for y-axis and specifying tick labels) is required to get expected figure.

Thank you.

@rougier
Copy link
Owner

rougier commented Jul 13, 2022

Thanks, can you make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants