Giter VIP home page Giter VIP logo

maplegend's Introduction

maplegend

R-CMD-check Codecov test coverage Project Status: Active โ€“ The project has reached a stable, usable state and is being actively developed.

Create legends for maps and other graphics. Thematic maps need to be accompanied by legible legends to be fully comprehensible. This package offers a wide range of legends useful for cartography, some of which may also be useful for other types of graphics.

Installation

You can install the released version of maplegend from CRAN with:

install.packages("maplegend")

Alternatively, you can install the development version of maplegend from GitHub (dev branch) with:

remotes::install_github("riatelab/maplegend", ref = "dev")

Example

The main function is leg(). Its type argument defines the legend type.

library(maplegend)
opar <- par(mar = c(1,1,1,1), mfrow = c(1,2))
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(type = "prop", val = c(10, 50, 100), pos = "topleft")
leg(type = "choro", val = c(10, 20, 30, 40, 50), pos = "bottomleft")
leg(type = "typo", val = c("A", "B", "C"), pos = "top")
leg(type = "symb", val = c("A", "B", "C"), pos = "topright")
leg(type = "prop_line", val = c(5, 50, 100), pos = "bottom", lwd = 20)
leg(type = "grad_line", val = c(1, 4, 10, 15), pos = "bottomright", lwd = c(1, 5, 10))
box()
plot.new()
plot.window(xlim = c(0, 100), ylim = c(-50,50), asp = 1)
leg(type = "prop", val = c(10, 50, 100), pos = "topleft", horiz = TRUE)
leg(type = "choro", val = c(10, 20, 30, 40, 50), pos = "left", horiz = TRUE)
leg(type = "cont", val = c(10, 20, 30, 40, 50), pos = "bottomleft", horiz = TRUE)
leg(type = "cont", val = c(10, 20, 30, 40, 50), pos = c(75, 25), horiz = FALSE)
box()

It is possible to create composed legends with leg_comp() and leg_draw().

opar <- par(mar = c(1,1,1,1))
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg_comp(type = "prop", val = c(10, 50, 100)) |>
  leg_comp(type = "typo", val = c("A", "B", "C")) |>
  leg_draw(pos = "top", bg = "lightblue", fg = "darkblue", frame_border = NA)
box()
par(opar)

Background

This package is primarily intended as a backend for the construction of legends in the mapsf package. However, it can also be used independently from mapsf with base plots or even with igraph plots.

Community Guidelines

One can contribute to the package through pull requests and report issues or ask questions here.
This project uses conventional commits and semantic versioning.

maplegend's People

Contributors

rcarto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

maplegend's Issues

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.