Skip to content

Improve the colorbar example #595

Closed

Description

@seisman

Description of the problem

We already have an example for colorbar in the gallery (https://www.pygmt.org/dev/gallery/plot/colorbar.html). However, the example is a little low-quality.

  1. The example gives many warnings like:

    colorbar [WARNING]: Axis sub-item f set more than once (typo?)
    colorbar [WARNING]: Axis sub-item a set more than once (typo?)
    
  2. The example is not beautiful at all. The main reason is that the figure size is too small and the colorbars are too large.

  3. The example is not as usable as I expect. I believe very few people will plot colorbars inside a frame. IMHO, at least we should show

    1. calling colorbar with very few arguments, using the default location and default size
    2. the easiest way (using J) to plot colorbars outside the basemap.

@weiji14 As the example was created by you, I'd like to hear what you think. You can improve the example if you like.

Activity

  1. weiji14 commented on Sep 10, 2020

    @weiji14
    Member

    Oo, those warnings definitely aren't nice to have, and yes, the example could definitely look a bit nicer, I got carried away with the different positioning methods at #373

    1. calling colorbar with very few arguments, using the default location and default size

    From memory, I don't think there's a default position and/or box (unlike legend which does). Will probably need to wrap in a few more long aliases to fig.colorbar to make this easier.

    1. the easiest way (using J) to plot colorbars outside the basemap.

    Yes, this would be good to show.

    Maybe we could reproduce (a subset) of the colorbars plotted at https://docs.generic-mapping-tools.org/latest/cookbook/cpts.html?

  2. seisman commented on Sep 10, 2020

    @seisman
    MemberAuthor

    From memory, I don't think there's a default position and/or box (unlike legend which does). Will probably need to wrap in a few more long aliases to fig.colorbar to make this easier.

    There are defaults. Try this example:

    import pygmt
    
    fig = pygmt.Figure()
    fig.basemap(region="0/10/0/10", projection="X10c/10c", frame=True)
    fig.colorbar(cmap="vik", frame=True)
    fig.savefig("map.pdf")

    However, I still don't like this one, because usually, what we do is calling makecpt to create a "current" cpt, plot some thing, and then calling colorbar without using cmap.

  3. weiji14 commented on Sep 10, 2020

    @weiji14
    Member

    From memory, I don't think there's a default position and/or box (unlike legend which does). Will probably need to wrap in a few more long aliases to fig.colorbar to make this easier.

    There are defaults. Try this example:

    import pygmt
    
    fig = pygmt.Figure()
    fig.basemap(region="0/10/0/10", projection="X10c/10c", frame=True)
    fig.colorbar(cmap="vik", frame=True)
    fig.savefig("map.pdf")

    However, I still don't like this one, because usually, what we do is calling makecpt to create a "current" cpt, plot some thing, and then calling colorbar without using cmap.

    Ah ok, then we should definitely show that this default position/style exists. I've opened a PR at #596, feel free to experiment on that branch or offer suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions