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

Added hatchmap function #107

Merged
merged 6 commits into from
Aug 8, 2023
Merged

Added hatchmap function #107

merged 6 commits into from
Aug 8, 2023

Conversation

sarahclaude
Copy link
Collaborator

Function to add hatching over maps using matplotlib contourf.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@review-notebook-app
Copy link

review-notebook-app bot commented Aug 3, 2023

View / edit / reply to this conversation on ReviewNB

juliettelavoie commented on 2023-08-03T19:43:48Z
----------------------------------------------------------------

ajoute hatchmap dans la liste.


@review-notebook-app
Copy link

review-notebook-app bot commented Aug 3, 2023

View / edit / reply to this conversation on ReviewNB

juliettelavoie commented on 2023-08-03T19:43:49Z
----------------------------------------------------------------

  1. J'ajouterais un exemple avec levels.
  2. ens_stats.prcptot_mean.mean(dim='time', keep_attrs='True') pour avoir un label de colorbar.


@sarahclaude
Copy link
Collaborator Author

I am trying to commit a file with the line (1965):

im = v.where(mask == True).plot.contourf(ax=ax, transform=transform, **plot_kw[k])

but the commits fails with :
flake8...................................................................Failed

  • hook id: flake8
  • exit code: 1
    figanos/matplotlib/plot.py:1965:31: E712 comparison to True should be 'if cond is True:' or 'if cond:'

Should I change the .where(mask==True)? @Zeitsperre

@Zeitsperre
Copy link
Contributor

Zeitsperre commented Aug 3, 2023

You should change it, yes. This is kind of an interesting read on why ==True is not a good idea, particularly in Python. (might help if I add the link: https://stackoverflow.com/a/27276841/7322852)

If the values of mask are a boolean array, mask is True is more Pythonic. Otherwise, if we are concerned about the "Truthyness" of mask (i.e. positive integers/floats), you can just use mask.

@sarahclaude
Copy link
Collaborator Author

Thanks!

@sarahclaude sarahclaude linked an issue Aug 7, 2023 that may be closed by this pull request
@review-notebook-app
Copy link

review-notebook-app bot commented Aug 7, 2023

View / edit / reply to this conversation on ReviewNB

juliettelavoie commented on 2023-08-07T19:47:14Z
----------------------------------------------------------------

j'ai des petites interrogations:

  1. level =4, mais je vois 3 patterns
  2. comment on a une fraction négative ? (-1<x<0.4)
  3. comment ça marche quand il y a des unités ?
  4. Est-ce que levels est vraiment utiles ?

sarahclaude commented on 2023-08-07T21:08:12Z
----------------------------------------------------------------

Levels est directement envoyer a matplotlib.contourf (If an int n, use MaxNLocator, which tries to automatically choose no more than n+1 "nice" contour levels between minimum and maximum numeric values of Z.

If array-like, draw contour lines at the specified levels. The values must be in increasing order).

Donc, c'est matplotlib qui gère le tout puisque je n'ai pas fait de fonction propre à figanos comme Alexis avait fait pour Gridmap et je n'ai pas spécifier d'intervalles.

Je penses effectivement que levels pourrait être retirer des arguments et si qqn veut l'utiliser ce sera une option de plot_kw. Est-ce que j'enlève l'exemple aussi?

Sinon, l'autre option ce serait de créer qqc de similaire à gridmap pour les niveaux et que ce ne soit pas pris en charge par matplotlib.contourf().

Copy link
Collaborator Author

Levels est directement envoyer a matplotlib.contourf (If an int n, use MaxNLocator, which tries to automatically choose no more than n+1 "nice" contour levels between minimum and maximum numeric values of Z.

If array-like, draw contour lines at the specified levels. The values must be in increasing order).

Donc, c'est matplotlib qui gère le tout puisque je n'ai pas fait de fonction propre à figanos comme Alexis avait fait pour Gridmap et je n'ai pas spécifier d'intervalles.

Je penses effectivement que levels pourrait être retirer des arguments et si qqn veut l'utiliser ce sera une option de plot_kw. Est-ce que j'enlève l'exemple aussi?

Sinon, l'autre option ce serait de créer qqc de similaire à gridmap pour les niveaux.


View entire conversation on ReviewNB

@sarahclaude sarahclaude merged commit 7bd4d01 into main Aug 8, 2023
7 checks passed
@sarahclaude sarahclaude deleted the pattern branch August 8, 2023 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pattern to gridmap
3 participants