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

shape donut #4

Closed
ericmelse opened this issue Oct 15, 2024 · 3 comments
Closed

shape donut #4

ericmelse opened this issue Oct 15, 2024 · 3 comments

Comments

@ericmelse
Copy link

Dear Asjad,

I am not sure when a shape option becomes a (new) plot as such.

But, now you have added the shape option pie that can be set to be 'sliced', like your example using start(0) end(270), I am driven to ask also for a donut with the same shape options.

In my view a donut chart/plot is a more effective unary data visualition tool than a pie chart/plot (there is a ton of literature debating this, should you be interested in that I can provide materials).
More pressing is that it is rather hard to draw a donut chart/plot using Stata.
Andrew Musau provided a working solution for that, published as a Stata Tip in The Stata Journal.
However, for that to work he still uses graph pie and next we have to work through a rather voluminous 'hack' using graph editor commands like:

sysuse census , clear
graph pie pop, over(region) scheme(sj) xsize(6) ysize(6) graphregion(fc(white) ilc(white) lc(white))
graph export "Example_Pie Chart1.png", width(1200) height(1200) as(png) replace // Change path as required

local csize=60
gr_edit .plotregion1.AddMarker added_markers editor .0715713654788885 -.0361049561829105
gr_edit .plotregion1.added_markers_new = 1
gr_edit .plotregion1.added_markers_rec = 1
gr_edit .plotregion1.added_markers[1].style.editstyle marker( symbol(circle) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(white) pattern(solid) align(inside)) fillcolor(white) size( sztype(relative) val(`csize'*(93/100)) allow_pct(1)) angle(stdarrow) symangle(zero) backsymbol(none) backline( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) backcolor(black) backsize( sztype(relative) val(0) allow_pct(1)) backangle(stdarrow) backsymangle(zero)) line( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) area( linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(ltbluishgray) pattern(solid) align(inside)) shadestyle( color(ltbluishgray) intensity(inten100) fill(pattern10))) label( textstyle( horizontal(center) vertical(middle) angle(default) size( sztype(relative) val(2.777) allow_pct(1)) color(black) position() margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside))) position(6) textgap( sztype(relative) val(.6944) allow_pct(1)) format(`""') horizontal(default) vertical(default)) dots( symbol(circle) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) fillcolor(black) size( sztype(relative) val(.1) allow_pct(1)) angle(horizontal) symangle(zero) backsymbol(none) backline( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) backcolor(black) backsize( sztype(relative) val(1.52778) allow_pct(1)) backangle(horizontal) backsymangle(zero)) connect(direct) connect_missings(yes) editcopy

which results in:
donut1
So, mildly stated, I am happy that Andrew was able to provide a working solution as such for creating a donut chart/plot but I certainly am eager for a more flexible solution for this unary visualization ability using Stata.

Now, I suppose the first step would be to have a graphfunction available like shape donut not only with the parameters to set the starting and the ending position of donut slices but also for the donut radius (width).
Once we have that available, I suggest to employ that in a (new) Stata package donut that you could enrich with those very fine options to control about anything you can think of. For example, byable sets of donuts plots over something, ordered in (#) rows or columns, legend controls, etc.

I do hope that the above is inspirational.

Best wishes,
Eric

@asjadnaqvi
Copy link
Owner

Dear Eric,

For a donut plot, you can already use sunburst. Maybe I should add an example there.

For graphfunctions I am still in the middle of putting it together, but I will add examples for how to generate donuts + other visualizations.

Also I am not a fan of this Stata basecode hacking that you posted above. This type of syntax from the base engine is not supposed to be used.

@asjadnaqvi
Copy link
Owner

@ericmelse here is a basic syntax:

ssc install sunburst, replace

sysuse census , clear
sunburst pop, by(region) full format(%15.0fc)

donut1

@ericmelse
Copy link
Author

Thank you Asjad, for your response and example.
I agree that 'Stata basecode hacking' is something of a 'last resort effort' when everything else seems to fail.
Yes, it is very nice to see how a donut chart/plot can be created by using your package sunburst
My first effort was by experimenting with options to redesign the result to my personal taste.
I will post that as a new issue with some questions on the sunburst Github page (so you can close this issue here).

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

No branches or pull requests

2 participants