Code Monkey home page Code Monkey logo

paint-box's Introduction

Paint Box

GitHub release (latest by date including pre-releases) GitHub Code style: black

Python code for building matplotlib color palettes and exporting them for use in either Inkscape or Gimp.

The story so far

I was in the middle of some code with a lot of matplotlib figures. Changing the figure palette within matplotlib is reasonably straightforward, but then... I was putting them on a poster, and adding them to a presentation - both of these applications needed other graphics from other sources to make sense, and I suddenly realised that I had no way of making my figures match the rest of the colour scheme.

This simple bit of code takes an input of an arbitrary number of colours, either in rgb or hex format, and uses them to generate 1) a range of matplotlib colormaps and 2) a .gpl file (gimp palette) containing the original colours, as well as a range of saturation and brightness options.

Uses

Once you have set up the object, you can either use PaintBox.basemap as a standard matplotlib colormap, or export the whole thing as either an array of swatches (small picture files) or as a palette to use in your favorite open-source graphics editor.

Basic commands

palette = [ a list of colours] It's easiest to set this up first. We can handle hex "#ffffff", rgb as (0.x,0.x,0.x) or rgb as (255,255,255) or as the equivalent lists: i.e. [0.x,0.x,0.x] or [255,255,255]

x = PaintBox("name",palette) generates the paintbox object

x.palette_path = r".\test" for inkscape, use r"C:\Users\your_name\AppData\Roaming\inkscape\palettes"

x.swatch_location(r".\test") wherever we want the swatches saved

x.swatches(save=True) save swatches of the colour scheme to the swatch_location

x.export(x.palette_path) save a GPL palette to the palette_path

Good sources of colour schemes include:

Swatch examples

  • Base Map

    Base Map

  • Lighter

    Lighter

  • Much Lighter

    Much lighter

  • Darker

    Darker

  • Much Darker

    Much darker

  • Desaturated

    Desaturated

  • Very Desaturated

    Very Desaturated

  • Saturated

    Saturated

  • Very Saturated

    Very Saturated

paint-box's People

Contributors

rollsw avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.