Nat  Grady

Nat Grady

1659735000

ggplot2: An implementation of the Grammar of Graphics in R

ggplot2

Overview

ggplot2 is a system for declaratively creating graphics, based on The Grammar of Graphics. You provide the data, tell ggplot2 how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details.

Installation

# The easiest way to get ggplot2 is to install the whole tidyverse:
install.packages("tidyverse")

# Alternatively, install just ggplot2:
install.packages("ggplot2")

# Or the development version from GitHub:
# install.packages("devtools")
devtools::install_github("tidyverse/ggplot2")

Cheatsheet

Usage

It’s hard to succinctly describe how ggplot2 works because it embodies a deep philosophy of visualisation. However, in most cases you start with ggplot(), supply a dataset and aesthetic mapping (with aes()). You then add on layers (like geom_point() or geom_histogram()), scales (like scale_colour_brewer()), faceting specifications (like facet_wrap()) and coordinate systems (like coord_flip()).

library(ggplot2)

ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point()

Lifecycle

ggplot2 is now over 10 years old and is used by hundreds of thousands of people to make millions of plots. That means, by-and-large, ggplot2 itself changes relatively little. When we do make changes, they will be generally to add new functions or arguments rather than changing the behaviour of existing functions, and if we do make changes to existing behaviour we will do them for compelling reasons.

If you are looking for innovation, look to ggplot2’s rich ecosystem of extensions. See a community maintained list at https://exts.ggplot2.tidyverse.org/gallery/.

Learning ggplot2

If you are new to ggplot2 you are better off starting with a systematic introduction, rather than trying to learn from reading individual documentation pages. Currently, there are three good places to start:

The Data Visualisation and Graphics for communication chapters in R for Data Science. R for Data Science is designed to give you a comprehensive introduction to the tidyverse, and these two chapters will get you up to speed with the essentials of ggplot2 as quickly as possible.

If you’d like to take an online course, try Data Visualization in R With ggplot2 by Kara Woo.

If you’d like to follow a webinar, try Plotting Anything with ggplot2 by Thomas Lin Pedersen.

If you want to dive into making common graphics as quickly as possible, I recommend The R Graphics Cookbook by Winston Chang. It provides a set of recipes to solve common graphics problems.

If you’ve mastered the basics and want to learn more, read ggplot2: Elegant Graphics for Data Analysis. It describes the theoretical underpinnings of ggplot2 and shows you how all the pieces fit together. This book helps you understand the theory that underpins ggplot2, and will help you create new types of graphics specifically tailored to your needs.

Getting help

There are two main places to get help with ggplot2:

The RStudio community is a friendly place to ask any questions about ggplot2.

Stack Overflow is a great source of answers to common ggplot2 questions. It is also a great place to get help, once you have created a reproducible example that illustrates your problem.

Author: Tidyverse
Source Code: https://github.com/tidyverse/ggplot2 
License: Unknown, MIT licenses found

#r #visualising #datavisualisation 

ggplot2: An implementation of the Grammar of Graphics in R

PyScript Tutorial | Data Visualisation with PyScript

Rethinking Data Visualisation with PyScript

In this tutorial, we're going to introduce PyScript and we will present how PyScript can change the way data visualisation can be designed and delivered for complex data science use cases.

PyScript leverages on the web browser to act as a ubiquitous virtual machine to deliver unprecedented Data Science use cases. Data Visualisation is the first and perhaps the most straightforward context in which PyScript can have its say. In this talk, we will present how PyScript can change the way data visualisation apps can be designed and delivered for complex data science use cases.


PyScript has great potentials to changing the way in which Data Science can be delivered and democratised completely. By running Python directly in the browser, you can really get the experience of running Python anywhere, any time using the browser as a ubiquitous Virtual Machine.

Data Visualisation is the first and perhaps the most straightforward context in which PyScript can have its say. In fact, PyScript enables the creation of self-contained data viz apps, bringing the full Scipy/PyData stack directly integrated with interactive data visualisation frameworks, e.g. bokeh or panel. There's more! PyScript also allows direct integration with Javascript, allowing the development of full-fledged data viz apps using well-known JS library like Altair or D3.js

In this talk, we're going to introduce PyScript and we will present how PyScript can change the way data visualisation can be designed and delivered for complex data science use cases.

#python #pyscript #datavisualisation

PyScript Tutorial | Data Visualisation with PyScript
Reid  Rohan

Reid Rohan

1656934391

Twitter Sentiment Visualisations

Twitter Sentiment Visualisations

A web app that uses data from Twitter combined with sentiment analysis and emotion detection to create a series of data visualisations to illustrate the happy and less happy locations, topics and times.

Introduction

This project aims to make Twitter data more understandable. It streams real-time tweets, or can fetch tweets about a specific topic or keyword - it then analyses this data using a custom-written sentiment analysis algorithm, and finally displays the results with a series of dynamic D3.js data visualisations.

The aim of the app is to allow trends to be found between sentiment and other factors such as geographical location, time of day, other topics...

It has a wide range of uses, from analysing the effectiveness of a marketing campaign, to comparing two competing topics.

Screen Shots

As part of the documentation there is one shot of each screen in it's current state. View screen shots here

Below is a sample of the 12 key screens. Overview of screenshots

Modules

Several open source node modules have been developed and published on npm as part of this project

Project Planning

Running Locally

Prerequisites - You will need Node.js, MongoDB and git installed on your system. You will also need Gulp and Bower, which (once node is installed) you can install by running npm install gulp bower -g. Also Yarn is recommended.

Get the files - git clone https://github.com/Lissy93/twitter- sentiment-visualisation.git then navigate into it with cd twitter-sentiment-visualisation

Install dependencies - yarn will install the npm node_modules, then should automatically kick off a bower install (if not, then just run it manually). If you are developing, you will need to use npm install in order to get the devDependencies too.

Set Config yarn run config will generate the config\src\keys.coffee file, which you will then need to populate with your API keys and save. Also check that your happy with the general app config in config/src/app-config.coffee.

Build Project - yarn run build will compile the project, from the source.

Start MongoDB - mongod will start a MongoDB instance (run in separate terminal instance). See instructions: Starting a MongoDB instance.

Run the project - Run yarn start then open your browser and navigate to http://localhost:8080

View detailed installation instructions

To run the tests: npm test or see the more test strategy

To run in development mode, use yarn run dev. This will use dev environmental variables, and also will watch for changes, lint, compile and refresh automatically.

Automated Development Workflow

TSV uses the Gulp streaming build tool to automate the development workflow.

The key tasks you need to run are:

  • gulp generate-config - before first-time running of the project, run this command to generate configuration files for your API keys
  • gulp build - This will build the project fully, this includes cleaning the working directory and then all tasks that must happen for CoffeeScript, JavaScript, CSS, images, HTML and Browserify tasks.
  • gulp nodemon - Runs the application on the default port (probably 8080)
  • gulp test - This will run all unit and coverage tests, printing a summary of the results to the console and generating more detailed reports into the reports directory.
  • gulp - this is the default task, it will check the project is configured correctly, build ALL the files, run the server, watch for changes, recompile relevant files and reload browsers on change, and keep all browsers in sync, when a test condition changes it will also re-run tests - a lot going on!

To read more about the project setup and gulp process, see build environment in the docs

Test Strategy

Twitter Sentiment Visualisation follows the TDD approach and is structured around it's unit tests.

To run tests: npm test

Testing Tools

More details on each of the tools and how they will be implemented along with the pass and fail criteria can be found on the test strategy page of the documentation.

The Stack

This project wouldn't have been possible at all without making use of many many open source packages, libraries, frameworks etc..

I would like to personally thank the hundreds of developers who have worked on open source packages like these.

There is an extensive stack of technologies that were used to develop the final application. The following list is a summary of the key utilities:

The Stack

Documentation

Project Information

Project Introduction

Addressing Potential Risks

System Development Life Cycle

Licence


Project Planning

User Stories

Complexity Estimates

High Level UML

Methodology - frontend

Test Strategy


Development Documentation

Installation Instructions

Build Environment

Testing


Research

The current sentiment analysis scene

Comparison of various sentiment analysis algorithm approaches

References


Read more about the application here.

The application is fully documented, which can be viewed here

Live Application

A live demo of the application has been deployed to: http://sentiment-sweep.com

Author: Lissy93
Source Code: https://github.com/Lissy93/twitter-sentiment-visualisation 
License: 

#javascript #d3 #datavisualisation 

Twitter Sentiment Visualisations

D3-iconarray: A D3 Module for Making Grids Of icons

d3-iconarray

A D3 plugin targeting V4 helping you to draw an array of icons.

examples

Why?

There are two parts to this plugin. First a layout which will assign x,y coordinates to elements of an array given some parameters. Second a scale which will put regular breaks in the array of icons to aid legibility.

API Reference

Layout

# d3_iconarray.layout()

Construct a new icon array layout function.

# layout([data array])

The function created by the above. When given an array of data will return an array containing grid positions as well as the original data. Unless a height or width restriction has been specified the layout will try to make the grid as square as possible. eg. a 100 element data array will result in a 10x10 grid.

example

var layout = d3_iconarray.layout();

var grid = layout([1,2,3,4]); 

/*
'grid' is

[
    {"data":1,"position":{"x":0,"y":0}},
    {"data":2,"position":{"x":1,"y":0}},
    {"data":3,"position":{"x":0,"y":1}},
    {"data":4,"position":{"x":1,"y":1}}
]

/*

You can use the resulting grid to plot icons, the data points will be arranged like this

layout 1

# layout.widthFirst([boolean])

This function sets the order in which points are arranged in the grid. if widthFirst is set to true rows will be filled before starting the next, if it's false columns in the layout will be filled first. if no argument is provided it returns the current value.

example

var layout = d3_iconarray.layout()
                    .widthFirst(true);

var grid = layout([1,2,3,4]); 

the resulting in the resulting grid the icons will be arranged like this

layout 2

with .widthFirst(false) they'll be arranged like this

layout 3

when to use the widthFirst switch (UK election results)

# layout.width([integer])

the width function defines the maximum number of elements the grid will have in a given row. if no argument is provided it returns the current value.

example

var layout = d3_iconarray.layout().width(3);
var grid = layout([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);

results in a grid like

layout width restriction

# layout.height([integer])

the height function sets the maximum number of elements the grid will have in a given row. if no argument is provided it returns the current value.

example

var layout = d3_iconarray.layout().height(3);
var grid = layout([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);

results in a grid like

layout height restriction

# layout.position([integer])

given the a number representing an array element this function will tell you it's {x, y} location in the grid. This function needs some dimension of the grid (height or width) to have been set explicitly (by height or width) or implicitly by passing a data array to the layout function

example

var layout = d3_iconarray.layout();
var grid = layout([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);

var p = layout.position(7);
// p is {x: 3, y: 1}

# layout.maxDimension([integer])

A bit like position but given a number will return the maximum extent of the lyout if it were to have that many elements. THis is useful for setting the domain of scales.

Scale

You can use any kind of scale to draw your grid to the screen. The scale provided by the plugin can let you add breaks to your icon array to improve legibility e.g. here's a 2500 element array grouped in to blocks of 100.

blocks of 100

# d3_iconarray.scale()

Creates a scale function just like good ol' d3.scaleLinear() etc.

# scale(x)

Given a value x in the input domain, returns the corresponding value in the output range.

# scale.domain([numbers])

Set the input domain, an array of 2 numbers.

If no arguments are provided this returns the current value.

# scale.range([numbers])

Set the output range, an array of 2 numbers.

If no arguments are provided this returns the current value.

# scale.gapInterval(x)

This function accepts a number which sets at what interval a gaps appear in the output range. i.e. if x is 10 there will be an extra gap after every ten items in the output range.

If no arguments are provided this returns the current value.

see this example

# scale.gapSize(x)

This sets how big the gaps in the output range will be relative to the normal spacing. So if the normal spacing between two whole numbers is 10px and the gap size is set to 1.5 the extra wide space will be 15px.

If no arguments are provided this returns the current value.

see this example

Why?

Twenty years ago, a psychological study compared for the first time rudimentary icon displays for communicating risk. Today, we have dozens of randomized experiments to support the use of icon arrays (sometimes referred to as “pictographs”) as an evidence-based standard in medical risk communication.

Why use Icon Arrays

Icon arrays are particularly effective, and are apparently less likely to increase patient anxiety than other graphical techniques.

Scientific American: Inadequate Data Visualization Leaves Patients Undereducated

Installing

If you use NPM, npm install d3-iconarray. Otherwise, download the latest release.

Examples

Author: Tomgp
Source Code: https://github.com/tomgp/d3-iconarray 
License: BSD-3-Clause license

#javascript #3d #icon #datavisualisation 

D3-iconarray: A D3 Module for Making Grids Of icons

Top 8 Julia Libraries For Data Visualisation

Julia is a preferred language for data science, artificial intelligence, and modeling and simulation applications. The language combines the ease of use of Python and R with the speed of C++, while providing parallel computing capabilities out of the box.

Read more: https://analyticsindiamag.com/top-8-julia-libraries-for-data-visualisation/

#julia #data-science #artificial-intelligence #datavisualisation

Top 8 Julia Libraries For Data Visualisation

A Complete Guide To Crack Tableau Certification Exam

Tableau is a popular platform for data visualisation which has been used by developers around the globe and has revolutionised the data visualisation space. According to reports, the global Tableau services market has been expected to grow at a CAGR of 13.3% during the forecast period of 2017-2028. Tableau is a flexible end-to-end analytics platform that helps in turning your data into insights that drive action.

Read more: https://analyticsindiamag.com/a-complete-guide-to-crack-tableau-certification/

#tableau #datavisualisation

A Complete Guide To Crack Tableau Certification Exam

7 Types Of Tableau Charts To Make Your Data Visually Interactive

Graphs and charts are the most expressive ways when it comes to showing enormous amounts of raw data in a simple manner. Tableau is known to be one of the most popular and trending data visualisations software among developers. It creates fast visualisations of data in the form of worksheets and dashboards.

Read more: https://analyticsindiamag.com/7-types-of-tableau-charts-graphs-to-make-your-data-visually-interactive/

#tableau #datavisualisation

7 Types Of Tableau Charts To Make Your Data Visually Interactive