過去記事「【SQL】年別総数とタイプ別割合」で作ったデータソースをもとに、Flourishで可視化します。Flourishは、テンプレ群がスタイリッシュでカラフルで目を引きます。動的なので、うまくはまれば自分がちょっと仕事出来る感じに思えてくる(錯覚)、ゲーマー向きなプラットフォームです。個人的視点。
- 使用データ:[ Google Cloud Public Datasets] chicago_crime_data (Chicago Police Department crime data from 2001 to present)
- 期間:2010-01-01 ~ 2020-12-31(10年間)
- 棒グラフ
- エリアグラフ
1.棒グラフ
まず完成形を。なにぶん犯罪タイプが多すぎて、凡例が場所取る。Flourishは入れたものをそのまま出すので、すっきりさせたかったらあらかじめカテゴリ「Other」とか作ってまとめたほうがいいです。データ画面で使うデータを制限(少ない凡例を除外)できるけど、そしたら総数と内訳トータルが一致しません。
設定
- Chart type:Column Chart(stacked)
- Stack sort mode:Normal
- Grid mode:Single chart
- Height mode:Auto
あとはヘッダータイトルくらい。
もちろん凡例ごとに色を変えることもできます。TableauもExploratryもそう。ただFlourishは、細かくコードで記述です。まあパレットも同じ事してるんですけど、THEFT:#0000ffとかBATTERY:purple,とか、30超ある凡例の手書きは避けたいところ。(オリジナル色パレットももちろんあります、お任せのやつ。全部に色つくけど。)
(↓整える前↓)Flourishは、「データソースの順番通り」に可視化します。なので、前回Exploratryで縦横変換した直後の並び順(アルファベット順)だと、こうなります。(色パレット、ほか設定はそのまま)
色面積が違うとこうも印象が違うのか。データの並びはアルファベット順、下からの順次積み上げです。ケーキだとこっちが美味しそうです。スポンジ+ソース+スポンジ+ジャム+コーティング的な。(どうでもいい)
前回記事「【Exploratry】ロング型からワイド型へのデータ変換③」の文末処理に「データ並び替え」があったのは、このためです。
データソースについていくつかの疑問:
【Exploratry】
どこでアルファベット順になったのか?
→変換する前は、グループ化(年+犯罪件数順)のロング型でした。ワイド型に変換する際、デフォルトでアルファベット順になったようです。現在、オプションで並び順の設定まではできない。例えばprymary_countの昇順、とか。
【Flourish】
Flourishのデータ画面で並び替えしないのか?
→可能です。ただし、列を選択して「一列前へ」「一列後ろへ」シフトで連続列指定で動かすことはできますが、Ctrl+の飛ばし選択はできません。かつ、あくまで画面上のマウス処理です。画面枠を外れた列を手作業で持ってくるのはいささか大変。
特定カテゴリ指定して並び順を変える、という観点では、SQLが早いです。ロング型ならね…。同じ手作業でもExploratryが断然早かったので、列カテゴリ並べ替えは前回記事内で終えました。2010年の犯罪件数昇順でそろえてます。
2.エリアグラフ
データが合ってれば、チャート型を変えるだけです。
設定:Chart type:Area Chart (stacked)
Flourishのさりげに細かくて好きなところ。Areaにすると、「Line curve」でStraight/Curve(Natural)/Curve(X)/Step など6種から選べる。今回は「Curve(Natural)」にしました。服のディテールを好みにできる感じでときめく。
********
Based on the data source created in the previous article "[SQL] Total number by year and percentage by type", the data is visualised in Flourish.
Flourish's templates are stylish, colourful and eye-catching. It is a platform that gamers like because it is dynamic and, if you get it right, it makes you feel like you can do a bit of work (illusion). Personal perspective.
- Data used: [ Google Cloud Public Datasets] chicago_crime_data (Chicago Police Department crime data from 2001 to present)
- Period: 2010-01-01 - 2020-12-31 (10 years)
- bar chart
- Area chart
1. bar chart
First of all, here is the complete picture. There are too many crime types, and the legend takes up too much space; Flourish will take what you put in and put it out. If you want a clean look, you should create a category 'Other' or something like that in advance and organise them. You can limit the data used on the data screen (exclude a few legends), but then the total number and the breakdown total will not match.
Settings.
- Chart type:Column Chart(stacked)
- Stack sort mode:Normal
- Grid mode:Single chart
- Height mode:Auto
The only other thing I changed was the header title.
Of course, you can change the colour for each legend, as you can with Tableau and Exploratry. But Flourish is a very detailed code description. Even if there is a palette, the content is the same doing. I don't want to handwrite a legend with more than 30 legends, such as "THEFT:#0000ff" or "BATTERY:purple". (There is, of course, the original colour palette.)
(↓ before alignment↓)
Flourish visualises the data "in the order of the data source". So, in the order in which the data sources were converted in Exploratry last time (alphabetical order), it will look like this. (Colour palette and other settings as they are)
Different colour areas give such different impressions. The data is sorted alphabetically, sequentially stacked from the bottom.
In a cake, this one looks delicious. Sponge + sauce + sponge + jam + coating. (Doesn't matter)
This is why the previous article "[Exploratry] Data conversion from long to wide type (3)" had "data sorting" as the end-of-sentence process.
Some questions about the data source:
【Exploratry】
Where did the alphabetical order come from?
→ Before the conversion, the long type was grouped (by year + number of crimes). When converting to the wide type, it seems to have become alphabetical by default.
Currently, it is not possible to set the sort order even in the options. For example, ascending order of prymary_count, and so on.
【Flourish】
You don't want to reorder on the Flourish data screen?
→Yes, you can. However, it is possible to select a column and move it by selecting 'one column forward' or 'one column back' to specify consecutive columns, but Ctrl+ cannot be used to skip selection. Also, this is only an on-screen mouse operation. It is somewhat difficult to manually bring in columns that are outside the screen frame.
SQL is faster for specifying specific categories and changing the sort order. If it is a long type...
I finished sorting by column category in the last article because Exploratry was the fastest way to do the same manual work.
2.Area chart
If the data is correct, simply change the chart type.
Settings: Chart type: Area Chart (stacked).
A favourite part of Flourish's detailed settings: if you select Area, you can choose from six different types, including Straight/Curve(Natural)/Curve(X)/Step in the 'Line Curve'. This time I chose Curve(Natural). I'm thrilled with the feeling of being able to choose the detailing of my clothes.
0コメント