Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve and document handling of linecolour and linetype #94

Open
1 of 2 tasks
gustavdelius opened this issue Sep 14, 2019 · 1 comment
Open
1 of 2 tasks

Improve and document handling of linecolour and linetype #94

gustavdelius opened this issue Sep 14, 2019 · 1 comment
Labels
enhancement New feature requests or suggestions for enhancement of existing features help wanted We are looking for someone to help with this issue plots Issue relates to plotting functionality

Comments

@gustavdelius
Copy link
Member

gustavdelius commented Sep 14, 2019

Currently the handling of the colour and linetypes used in mizer plots is a mess. There are some good aspects to it, but they are undocumented and hidden in the mess. It would be really good if someone could clean this up.

Here is a description of how things are handled at the moment:

There are two slots in a MizerParams object:

  • @slot linecolour A named vector of colour values, named by species or resource or other type (e.g. "fishing"). Used to give consistent colours in plots. Used not only for line colours but also for fill colours.
  • @slot linetype A named vector of linetypes, named by species or resource or other type. Used to give consistent line types in plots.

When a new MizerParams object is created with emptyParams(), these slots get initialised with hard-coded values, except where the user included columns linetype and linecolour in the species_params data frame. This happens in lines 575 and following in the file MizerParams-class.R.

The mizer plots, which are created with ggplot2, then use the @linecolour slot via scale_colour_manual() and scale_linetype_manual().

The @linecolour and @linetype slots are also modified in the functions addSpecies(), removeSpecies() and renameSpecies(), for obvious reasons.

Linetypes and linecolours for unstructured resources are currently set in setResourceDynamics(), but because the code for unstructured resources is going to be taken out of mizer again, to be placed into a mizer extension, you can ignore that code. But the message is that extensions will need to be able to add extra entries into the linecolours and linetypes slots or whatever takes their place in your improved scheme.

There are two very desirable goals for any improvement:

  • The setting of line colours and types should be documented

  • The default colour palette should not be hardcoded but changeable by the user, possibly by setting an options variable.

In addition, it would be nice to make the code a bit more elegant and robust.

@gustavdelius gustavdelius added enhancement New feature requests or suggestions for enhancement of existing features plots Issue relates to plotting functionality help wanted We are looking for someone to help with this issue labels Sep 14, 2019
@gustavdelius
Copy link
Member Author

In the documentation of this feature, you could also point users to sources of good colour schemes. Some were mentioned in the discussion at #63

gustavdelius added a commit that referenced this issue Aug 25, 2021
…ually changes the linecolours and linetypes as intended. Also improved documentation. See #94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature requests or suggestions for enhancement of existing features help wanted We are looking for someone to help with this issue plots Issue relates to plotting functionality
Projects
None yet
Development

No branches or pull requests

1 participant