GithubHelp home page GithubHelp logo

abstractgeek / categoricalscatterplot Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 63 KB

[MATLAB] An improved box plot that shows the data-points along with the median and the quartiles.

Home Page: https://in.mathworks.com/matlabcentral/fileexchange/60705-abstractgeek-categoricalscatterplot

License: MIT License

MATLAB 100.00%
matlab matlab-toolbox boxplot scatter-plot

categoricalscatterplot's Introduction

Categorical Scatter plot (Box Whisker plots with data points)

A replacement for the traditional box and whisker plots provided in MATLAB (command boxplot). The categorical scatter plots additionally shows the data points, which is useful the visualize the underlying distribution (similar to violin plots).

Examples

The code is designed to be an extremely customizable alternate for the built in boxplot function in MATLAB. The syntax is very similar to that of boxplot. Below are some example usages for the function.

Example 1: Using CategoricalScatterplot instead of boxplots

% load a sample dataset
load carsmall
% Use matlab's boxplot
boxplot(MPG,Origin)
title('Miles per Gallon by Vehicle Origin')
xlabel('Country of Origin')
ylabel('Miles per Gallon (MPG)')

The traditional box plot of the car sample dataset looks like this:

% Use CategoricalScatterplot
CategoricalScatterplot(MPG,Origin)
title('Miles per Gallon by Vehicle Origin')
xlabel('Country of Origin')
ylabel('Miles per Gallon (MPG)')

The categoricalscatterplot of the same sample dataset looks like this:

Example 2: Customizing CategoricalScatterplot plots

% A minimalistic categorical scatter plot
CategoricalScatterplot(MPG,cellstr(Origin),'WhiskerLine',false,'BoxColor',[0.8471 0.8627 0.8392],'WhiskerColor',[0.8235 0.7412 0.0392])

Categorical Scatter plots can easily be customized using the input arguments to the function. Here is a minimalistic version of the above plot:

Syntax

Required Inputs:

X - Input Data - vector or a matrix (Group required if X is a vector)

Optional Inputs:

  • Group - Grouping variables - vector
  • 'Color' - nx3 matrix for n groups or 1x3 vector for all groups or a character color ('k', 'r', etc) for all groups
  • 'Labels' - A cell string containing labels for all the groups

####Plot parameters (to tweak style): Scatter parameters:

  • 'binWidth': Sets the bin width that is used to stagger points along the xaxis in the scatter plot. Smaller binwidths imply that the points will be close to the central line. Larger values will make the points distributed all over the box.
  • 'binWidthRatio': Easier way of setting binwidth. It calulates the binwidth automatically based on the value range of points (Y axis range).
  • 'spreadWidth': Sets the extent of the point spread on the x axis.
  • 'boxWidth': Sets the width of the boxes.

Plotting styles:

  • 'Marker': Marker type - char
  • 'MarkerSize': Marker size - num
  • 'FillMarker': Logical (true or false / 0 or 1)
  • 'BoxColor': char ('r') or rgb vector ([0 0 1])
  • 'BoxEdgeColor': char ('r') or rgb vector ([0 0 1])
  • 'MedianColor': char ('r') or rgb vector ([0 0 1])
  • 'WhiskerColor': char ('r') or rgb vector ([0 0 1])
  • 'BoxAlpha': Transparency of the box. num (0 to 1)
  • 'BoxLineStyle': char ('-')
  • 'MedianLineStyle': char ('-')
  • 'WhiskerLineStyle': char ('-')
  • 'BoxLineWidth': num (2.0)
  • 'MedianLineWidth': num (2.0)
  • 'WhiskerLineWidth': num (2.0)

categoricalscatterplot's People

Contributors

abstractgeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

shivanshdave

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.