Hi there: First, Happy 25-year birthday Google!!!
2 days ago, I wrote a program to show a circular pi chart by imitating the demo example of my e-book. The currect circular pi chart showed up after my 2nd try. However, What suprised me is the body of the program written by the author. The top image shows the program dictated by the author, and the bottom image is the one written by myself. Three obvious differeces:(1) URL, the URL of the author is kernal (2) The author’s program does NOT need the first 3 standard lines (3) In line 5, the author dictates N. mine N, because line 5 is an expression that’s why N must be followed by comma NOT dot . This problem lingers in my mind for 2 days and I stiil can NOT find a reasonable explanation. My only suspision is the word “kernal” shown at the URL which allows the author to successfully draw the chart. Can anyone give me a correct explanation? Thanks.
- The notebook URL is irrelevant for the body of the notebook. It may contain info that it’s a Python3 notebook, but has no impact on the code in the notebook.
- The np.linspace signature can be looked up if you run
You are right that there needs to be a comma after N. So, I assume that top picture is just an unsharp .png. Which could also explain why your see it as “kernal”.
- Please don’t post pictures (and tell your author to also not do so) but just use text (unless you need to show some graph or so). That avoids this kind of conundrum (also saves bandwidth and avoids any security risks with .pngs).
Hans, but why NONE of the top 3 lines show up in the author’s program? That’s the point, I think. From my perspective, without them, it’s impossible to draw the chart. Don’t you think so?
At least the first two lines, the two imports, are present in the author’s code just as in yours; they just aren’t visible in the screenshot as the page is scrolled down past them; you can see the two blank lines the author left under them. Which, to @hansgeunsmeyer , is why a screenshot is a not so good way of sharing one’s code. The third line sets the plotting backend to
inline, which may affect whether plots show up in the notebook as opposed to in a separate window, if it not already set automatically by Jupyter Notebook, though it does not fundamentally change the operation of the core code itself.
See my answer to this question in the other thread. In short, look carefully at the code for what determines the sectors (width and radaii) shown in the chart, and you should spot why your results are, as you would expect, different from that of the author…
Also, as an administrative note, it’s considered polite to avoid posting the same comment four times in the same thread, just to try to ping multiple people by replying to their posts. Instead, simply reply once, and anyone available should see it; if you really want to manually ping multiple people, you can just
@ each of them in the post instead of posting one duplicate reply for each person.
For now, I restored your original comment not replying to anyone, and removed the other three duplicates.