Pie charts in Qgis - r

I have this problem:
I would like to create a pie chart from a column of a attribute table, and I would like to see this pie chart above the map. The column contains names not nubers...
I work with marine species distribution data and I built a database of records of many many species...
In the specific, I have a column, called 'species', where there are many records (names) of some marine species. Several species may have many records, other species may have only a few numbers of records, so my objective is to graphically see the distribuition of records among the species.
If build a pie chart is a very time consuming procedure, I'd be happy to create a new column of the attribute table with the numbers of different species per year (see the attachments) or to try a totally new approach with R.
Thankyou for your help
img1 http://postimg.org/image/rn56c8l4z/
img2 http://postimg.org/image/e6918ynmj/

You'll most probably get many answers that pie charts are evil because they distort perception.
But along with better alternatives, namely stacked bar charts, you find code examples here
and, as always,
? pie
helps.
You may need to summarize your factor first, e.g. by table.

Related

I want to represent one persons numerical data graphically on rstudio

I have data on excel and I want to represent one persons data graphically in bar charts beside each other. All the values are numerical and I want it to look something like this:
where the w,x,y represent different variables like games played and turnovers and the three colours represent three different people. I have data on 20 people.
I don't know how to single out the individual data or represent multiple data points on the barchart.
Any questions, I'll try to describe as best as I can. Thanks in advance.

Power View - Tables with columns of the similar data

Apologies in advance if my question is obvious but I'm new to this and having spent days searching and experimenting I cannot achieve the result I'm after.
I have a big table of data that I want to plot some graphs for, namely stacked columns and then filter these using other criteria such as date. I came across Power View and have been learning to use it hoping it will let me produce the reports I'm after rather than standard Excel graphs which are very clunky.
An example of the sort of data my tables contains is as follows although I have a lot of other columns and about 20 of the similar metric columns:
]
And this is the sort of graph I want to plot:
]
Where the red sections correspond to "R0" values, the orange "R1" and the green "R2" - they're essentially a rating; poor, ok and good. I can plot a single metric versus the items column with the stacked bar fine but cannot find a way to plot the metrics long the x axis for say a given item or sum of all items.
I've created measures using CALCULATE to filter by the rating but when I try and plot these my only option in power view is a clustered column graph where the x axis is the rating and the legend is the metrics.
I also created another small table with a single column of R0, R1 and R2 but can only link that to one metric column whereas I need it to link to all of them.
I think it's potentially a many to many mapping issue and have found a lot of links covering bridge tables and the magic CALCULATE function.
However as I'm trying to map values in a column to several other columns it doesn't seem to quite fit the many to many problem or if it does I can't see it.
I feel like what I'm after should be quite simple but I either end up with all my metric columns being made to show identical values or there's loads of cross filtering that I don't want. The "ratings" for each metric are essentially independent and I don't want to combine them in any way.
Any help is greatly appreciated and if my solution is in the links I've listed above then I'd really appreciate a bit of help with seeing it.
Thanks in advance

ggplot2: Impossible to create stacked bar chart WITHOUT reshape/melt?

I am a novice at R and experimenting with as an alternative for data visualisation.
I am having trouble creating a stacked bar chart.
I have tried the reshape2 package with the melt function and have successfully produced one, but I had to explicitly create a dataset containing JUST the x-axis and variables that I want stacked.
It seems extremely counter-intuitive to me that we can't visualise data from a left to right sense (x-axis constant, y variables summed and overlapping).
Is there an alternate method, where I could simply perform a ggplot with the logic of:
ggplot(data=dataset, aes(x=Time, y1=var1, y2=var2, y3=var3.....)) +
geom_bar(stat="identity",position="stack")
where y1, y2, y3 are the variables I want stacked, but do not have corresponding flags for me to use a "fill=flag" type?
I basically want to work off one large master dataset and export multiple analysis without having to excessively isolate each dataset and melt it
In general a stacked bar chart is used to distinguish between variations within a single category of data. For example if you had a bar chart showing the population of three species of migratory fowl that inhabit one specific marsh.
The bars might be mallard ducks, muted swans & Canada geese. Each would have a single whole bar.
The stacking would come in when you looked at these with a trait or quality they might share which you were comparing, such as the number who migrate and those who overwinter locally. The population of each type of fowl would be split into two stacks in the bar, those migrating who are Canada geese, those not...and so on.
It is not really meant to bring together disparate traits into a stack.
So, if you have data that separates out categories of the same population, reshaping the data to create a set of individual types within your data in columns, then differentiating by factors in another (also all in the same column) that is the right move.
If you need to keep it extracted for some reason, you can probably use y = (x$1 +x$2 x$b) to create your stacks, but depending on the data that might fail miserably. The best thing to do is reshape so that the quality you are counting is in a column and you compare those members across some other column with stacks.
If you need to use the data in another format later, create a temporary table, plot and then remove() it and gc() after graphing to get your memory back

How do I plot two values against each other in tableau

I have two values I wish to plot against each other in tableau. They are two totals aggregated around the same date. I can get them to the point where they are plotted on a dual access against the date like so:
but any attempt to plot them against each other for correlation has come to nothing. I've tried simple conversion to scatterplot, using calculated fields, using a cross tab with subtitles and attempting to only plot the subtotals against each other all of which have failed. I could do it in Excel but have to do it in tableau.
I have consulted the official Tableau 9.0 guide, google and existing questions on Stack Overflow all to no avail. If I was doing this in BOXI, I could just select the columns and chart them. How do I do the equivalent visualisation in Tableau?
You aren't clear about what type of chart you want to make.
Do you want a scatter plot? If so, put one measure on the row shelf, the other measure on the column shelf, and one or more dimensions (such as your date) on the detail shelf to define how finely to aggregate the data. Check the aggregation functions you use (SUM, AVG) and the aggregation level for your date fields (YEAR, MONTH ...) as desired. You probably want to use the second block of date aggregations on the menu unless you want to group all January data together regardless of year.
If you want a connected scatter plot, set the mark type from automatic to line and move the date field from the detail to the path shelf. You might also then want to put the date on size, color or legend to visually show the direction of time on the line. You might need to change that field to attribute in some cases to avoid creating multiple lines.
Tableau is fantastic once you learn how it works, and get a strong understanding of how choices about treating fields as dimensions or measures, or discrete or continuous impacts the behavior. If you skim over those details, you can still make beautiful charts by following recipes, mimicking examples (and asking StackOverflow), but Tableau's behavior will seem mysterious and arbitrary.
If you take some time to learn the fundamentals about how Tableau works, it will repay your time investment. I recommend Joshua Milligan's book Learning Tableau for a good way to start, along with the training videos on the Tableau website.

Plot map of points spread into grid sub-samples

I'm trying to generate a map that looks like this in R:
The boxes represent individual observations, while the colors represent data pertaining to those individual observations. Anyone have any idea how this might be accomplished?

Resources