Is it possible to create a pie in pie chart in SPSS or R? - r

I know it is possible to create such double pie charts in excel like this:
http://chandoo.org/wp/2009/12/02/group-small-slices-in-pie-charts/
but can SPSS or R do this also?

In relation to R:
The answer to the title question is "yes" ... see ?pie
As for the second question, the one in the body - it would be possible but would involve some coding. You'd have to draw two pie charts side by side (which could be managed with two calls to pie) and use segments or arrows (and text if necessary) to do the additional components of the plot.
Here's a rough example:
That required the fig argument of par to get them side-by-side.
(That example required a little fiddling to get right, but it would be possible to write a function to automate the details.)
The main issue I can see would be 'why on earth would you do it?' -- pie charts are a poor way of conveying information of this form. There are alternatives that result in much better ability to distinguish values, and less bias (such as what you get when comparing nearly horizontal vs nearly vertical slices).

Related

plot panel visualization using ggplot2 in R shiny

I am implementing a R shiny with a plot panel implemented by library(ggplot2). If there are 12 plots, the layout looks great. Please check below.
12-plot layout
However, if I increase the plot number to 70, then each plot looks being compressed (pls see below). Is that possible I can keep the size of each plot fixed? Thank you so much!
enter image description here
Is there another way to approach this? For instance, can you group your data by two categorical variables and use on for colouring and the other for facetting? In that way, you may be able to reduce the number of facets, and stick with the larger facet size, while still conveying all relevant information? 70 facet plots is a lot!
Is this more of a QC thing? For QC, I tend to break it into groups by condition as Paul was suggesting. The reason is that within a condition, things should be really similar. Outside a condition, all bets are off. When I do this for genomics data, I tend to use “pairs” customized to my liking.
What don’t you like about the 70 sample display? Simply the change in aspect ratio? IMO, these are the things I don’t like about ggplot. You can make these plots using base R and then place them on a page manually using par or layout. For that matter, you can do the same with ggplot and use ggarrange or a different manual layout function to place the plots. All wrapped in a for or apply of course.
The other things I like to do when I have a LOT of QCs to look through is create a movie. I can use the forward/back buttons and go through a lot quickly. I like the idea of having this in a dashboard, nice one!
you could also try coord_fixed(ratio= ), not sure if that will work with faceting or not
Finally, I have made a movie-like visualization for those 70 plots using the plot_ly function in R package "plotly".

how to de-clutter graph created using proc gchart?

I utilized proc gchart in SAS and the following code to generate the graph displayed here.
proc gchart data=combined;
vbar distrct / discrete type=sum sumvar=PERCENT
subgroup= population coutline=gray width=6;
run;
However, as you can see it seems that individual variable bars are stacked extremely close together and is difficult to comprehend. I have 110 variable bars representing densities of ethnic groups
My question is
is there a way to make this graph look less cluttered (I tried reducing the width but it does not seem to work)?
Should I be using a different procedure than the g chart procedure?
2 is easier to answer; proc gchart is mostly replaced by proc sgplot nowadays. It's still maintained, but I don't think much new work is being done in gchart or the other sas/graph procedures.
As for how to make it better; there are some answers, definitely, for how to improve it, but ultimately trying to show 110 bars each split by four ethnicities, means your'e showing 440 data points on one graph. That's going to be a tough lift no matter what.
The first thing I'd consider is switching to horizontal. Horizontal may allow you to have a larger graph, allowing for more spacing, and often times readers have an easier time reading horizontal charts when combining that with stacked bar charts. Scrolling is also easier up-down for most people (a mouse wheel), so if it's okay that they not see it on one screen this may be better. It also allows the bar titles to be presented in the usual left-to-right manner.
Second, consider if your bars can be grouped together. Do you have regions or such that allow you to group bars together, with a bit more spacing between the region? Or more importantly, are there bars that you'd like the readers to be comparing visually to each other? Right now it looks like it's sorted alphabetically, but that is probably not the right way to sort it if there's any sort of relationship between the bars. For example, does the area have sub-areas that are ethnically related? Maybe group those together; or by just geographies (here is the north-east section, here's the east, here's the south-west, etc.) Any time you can group like-things together it makes it easier for the reader to understand what they're looking at and draw sensible conclusions.
You could also sort them by a particular racial makeup - say, in descending order of "color" which seems the dominant population group - which is often an effective way to present data that's this cluttered, as a reader can both see the trend and can find, say, their neighborhood and see where it falls in the order just by looking.
Best overall though might be to group the district up and then display that, so you have many fewer bars. If there's a sensible way to do that, that'll get your idea across more effectively.

Complex domain graphs

Source of image : https://math.stackexchange.com/questions/144268/is-there-a-name-for-this-type-of-plot-function-on-complex-plane-vs-time-shown
I had in one of my lectures a graph of how sin, cos and exp are related in complex domain with a figure that close to that one. I searched on-line a lot until I found that picture on Math.SE.
As per my search I found that it is only PTC mathcad that is stating it is possible to draw complex domain graphs but couldn't find any information related in mathcad manual or even in books including such graphs. Did any one managed to have such graphs drawn before. I would appreciate it as it will help me imagine graphically the circulation of complex numbers and the changes in formulas.
Can any one help?
In Mathcad, use CreateSpace with the appropriate functions of time. You'll have to open the plot dialog box to set the various axis and backplane options. You'll also need to ensure that each of the 3 plot elements is set to Data Points rather than Surface (the default display for the 3D plot component).
I typed the plot's expressions for exp, sin and cos elsewhere in the worksheet and then dragged them onto the plot.

How to draw pie of pie or bar of bar charts in R (using ggplot2)? [duplicate]

I know it is possible to create such double pie charts in excel like this:
http://chandoo.org/wp/2009/12/02/group-small-slices-in-pie-charts/
but can SPSS or R do this also?
In relation to R:
The answer to the title question is "yes" ... see ?pie
As for the second question, the one in the body - it would be possible but would involve some coding. You'd have to draw two pie charts side by side (which could be managed with two calls to pie) and use segments or arrows (and text if necessary) to do the additional components of the plot.
Here's a rough example:
That required the fig argument of par to get them side-by-side.
(That example required a little fiddling to get right, but it would be possible to write a function to automate the details.)
The main issue I can see would be 'why on earth would you do it?' -- pie charts are a poor way of conveying information of this form. There are alternatives that result in much better ability to distinguish values, and less bias (such as what you get when comparing nearly horizontal vs nearly vertical slices).

visualization - size of circle proportionate to the value of the item

I'm getting familiar with Graphviz and wonder if it's doable to generate a diagram/graph like the one below (not sure what you call it). If not, does anyone know what's a good open source framework that does it? (pref, C++, Java or Python).
According to Many Eyes‌​, this is a bubble chart. They say:
It is especially useful for data sets with dozens to hundreds of values, or with values that differ by several orders of magnitude.
...
To see the exact value of a circle on the chart, move your mouse over it. If you are charting more than one dimension, use the menu to choose which dimension to show. If your data set has multiple numeric columns, you can choose which column to base the circle sizes on by using the menu at the bottom of the chart.
Thus, any presentation with a lot of bubbles in it (especially with many small bubbles) would have to be dynamic to respond to the mouse.
My usual practice with bubble charts is to show three or four variables (x, y and another variable through the size of the bubble, and perhaps another variable with the color or shading of the bubble). With animation, you can show development over time too - see GapMinder. FlowingData provides a good example with a tutorial on how to make static bubble charts in R.
In the example shown in the question, though, the bubbles appear to be located somewhat to have similar companies close together. Even then, the exact design criteria are unclear to me. For example, I'd have expected Volkswagen to be closer to General Motors than Pfizer is (if some measure of company similarity is used to place the bubbles), but that isn't so in this diagram.
You could use Graphviz to produce a static version of a bubble chart, but there would be quite a lot of work involved to do so. You would have to preprocess the data to calculate a similarity matrix, obtain edge weights from that matrix, assign colours and sizes to each bubble and then have the preprocessing script write the Graphviz file with all edges hidden and run the Graphviz file through neato to draw it.

Resources