Code Monkey home page Code Monkey logo

colorbrewer's Introduction

ColorBrewer

make use of color palette from http://colorbrewer2.org in Mathematica

This is my first package written in Mathematica. This package provide a simple wrapper for ColorBrewer.

Usage

<<ColorBrewer`
GetPalette[PaletteName,ColorNumber] 
(*Get the palette with ColorNumber colors under palette with name PaletteName *)
CreateColorFunction[PaletteName,ColorNumber]
(*Get a ColorFunction with ColorNumber colors by palette named PaletteName *)

Example

Plot[Evaluate@Table[Sin[i x], {i, 1, 4}], {x, 0, 2 Pi}, 
 PlotStyle -> GetPalette[Set1, 4]]

ex1

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
 ColorFunction -> 
  Function[{x, y, z}, CreateColorFunction[RdYlBu, 5][z]]]

ex2

Reverse the ColorFunction with the third argument in CreateColorFunction.

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
 ColorFunction -> 
  Function[{x, y, z}, CreateColorFunction[RdYlBu, 5, True][z]]]

ex3

You may also use GetPalette to check the color palette first, such as [Assigning the third argument to True to get a reversed palette.]

pal

You may also display a list of palettes, such as following predefined ones with DisplayPalettes

SequentialPalettes ={"Reds", "YlOrRd", "RdPu", "OrRd", "PuBu", "Greens", "GnBu", 
	"BuPu", "Greys", "Oranges", "YlGnBu", "BuGn", "YlOrBr", "PuRd", "Blues", "PuBuGn", 
	"YlGn", "Purples"}
DivergingPalettes ={"Spectral", "RdYlGn", "PRGn", "RdBu", "RdGy", "RdYlBu", "PiYG", "PuOr", "BrBG"}
QualitativePalettes = {"Pastel2", "Pastel1", "Dark2", "Accent", "Paired", "Set1", "Set2", "Set3"}

pal

Feedback

Open an issue in the tracker.

colorbrewer's People

Contributors

wanglongqi avatar

Watchers

James Cloos avatar Nico Scherf avatar

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.