Skip to content

Units from 3rd axis applied to 4th plot #68

@dmoored4

Description

@dmoored4

I have a surface that is drawn in 3D space (length x, y, and z) with a 4th axis, the colorbar, which could be unitless, time, pressure, or some other dimension. The issue is that the colorbar title keeps the units from the 3rd axis (m). If I try to color based on anything other than a unitless number or a length, I get an error. If I could rename the colorbar_title = "Real Title ($real_units)" I would just strip out those units myself, but the other unit stays in so the title would be: "Real Title (kPa) (m)".

begin
    X = [1u"m", 1u"m"; 1u"m", 1u"m"]
    Y = [1u"m", 1u"m"; 1u"m", 1u"m"]
    Z = [1u"m", 1u"m"; 1u"m", 1u"m"]
    C = rand(2,  2)
    surface!(X, Y, Z, surfacecolor=C, color=:turbo, colorbar=true, colorbar_title="this should change (kPa)")
end

image

I considered rolling my own for this, but I have other elements like the ball being brought into the plot using UnitfulRecipes so I would either have to enforce that everything comes in using the correct units or handle it elegantly or not use UnitfulRecipes for any of it and roll my own for the whole thing.

I've only just started making recipes of my own so when I open the code base it's a little beyond me. I think two potential solutions would be:

  1. Allow a user to turn off the automatic units application to a specific axis
  2. Have the colorbar pick up the units of the series its plotting

Please let me know if I've missed an easy solution or I'd be happy to contribute a solution with a little direction. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions