File:Contribution size 2012 - pie.png

From Meta, a Wikimedia project coordination wiki

Contribution_size_2012_-_pie.png(690 × 426 pixels, file size: 35 KB, MIME type: image/png)

This is a file from the Wikimedia Commons. The description on its description page there is copied below.

Description
English: Donation distribution spanning July 1st, 2012 - Dec 28, 2012.

pie.sql:

-- mysql -BN civicrm < pie.sql

set @start = "20120701";
set @end = "20121228";

SELECT 10, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount BETWEEN 0 AND 10;
SELECT 30, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount BETWEEN 10 AND 30;
SELECT 50, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount BETWEEN 30 AND 50;
SELECT 100, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount BETWEEN 50 AND 100;
SELECT 200, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount BETWEEN 100 AND 200;
SELECT 1000, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount BETWEEN 200 AND 1000;
SELECT 250000, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount BETWEEN 1000 AND 250000;
SELECT 1000000, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount BETWEEN 250000 AND 1000000;
SELECT -1, SUM(total_amount), AVG(total_amount), COUNT(total_amount)
    FROM civicrm_contribution
    WHERE (receive_date BETWEEN @start AND @end) AND total_amount > 1000000;

pie.R:

# R --no-save < pie.R && ps2pdf "contribution size - pie.ps" && convert "contribution size - pie.pdf" "contribution size 2012 - pie.png"

# tsv, actually, but this suffix helps *office not have a cow
input_file = "splitamounts.csv"

subtitle = "(2012 fund season)"
output_format = "ps"
 
# TODO make from column 1
interval_labels = c("less than $10", "$10 to $30", "$30 to $50", "$50 to $100", "$100 to $200", "$200 to $1,000", "$1,000 to $250,000", "$250,000 to $1M", "$1M and up")
    #lab = paste(levels(dollar_range_endpoints), "\n", signif(avgs, 2)),
    # t("less than %C") t("%C to %C") t("%C and up")
 
start_output_capture = function(label)
{
    output_path = paste("./", label, ".", output_format, sep="")
    postscript(file = output_path)
}
 
 
data = scan(
    file = input_file,
    skip = 0,
    what = list( top=0, sum=0, avgs=0, counts=0 )
)
 
start_output_capture("contribution size - pie")
data$areas = data$counts * data$avgs
data$portions = data$areas / sum(data$areas)
str_means = formatC(
    signif(data$avgs, 4),
    format = "f",
    digits = 2,
    big.mark = ","
)
labels = gettextf(
    "%s\n (%d%% of total, mean $%s)",
    interval_labels,
    round(data$portions * 100),
    str_means
)
pie(
    data$areas,
    lab = labels,
    main = paste("Relative contributions to total, by donation size", subtitle),
    col = heat.colors(length(data$avgs)),
    init.angle = 45,
    radius = 0.7
)
dev.off()
Source mw:File:Contribution size 2012 - pie.png
Author Adam Roses Wight
Permission
(Reusing this file)
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 3.0 Unported license.
Attribution: Adam Roses Wight
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

image/png

f2acebbd8d7b52eb1c3b3a4cf9310164dfcc1e3b

35,366 byte

426 pixel

690 pixel

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current22:07, 17 September 2013Thumbnail for version as of 22:07, 17 September 2013690 × 426 (35 KB)Pcoombe (WMF)move title down and crop a bit more
22:05, 17 September 2013Thumbnail for version as of 22:05, 17 September 2013690 × 462 (35 KB)Pcoombe (WMF){{Information |Description ={{en|1=Donation distribution spanning July 1st, 2012 - Dec 28, 2012. pie.sql: <source lang="sql"> -- mysql -BN civicrm < pie.sql set @start = "20120701"; set @end = "20121228"; SELECT 10, SUM(total_amount), AVG(total_a...

There are no pages that use this file.

Metadata