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

Plot x guides only for non None x_labels #541

Open
inferrna opened this issue Jun 30, 2023 · 0 comments
Open

Plot x guides only for non None x_labels #541

inferrna opened this issue Jun 30, 2023 · 0 comments

Comments

@inferrna
Copy link

I need to plot a linear graph with labeled and guided points of interest.
I provided x_labels as [None, None, "Interesting point 1", None, None, "Interesting point 2"] but show_x_guides just showed all lines, so it just became not informative frequent mesh.
this patch did the job for me, but it also will trigger with empty strings provided by user as a labels.

--- a/pygal/graph/graph.py
+++ b/pygal/graph/graph.py
@@ -179,7 +179,7 @@ class Graph(PublicApi):
                 continue
             guides = self.svg.node(axis, class_='guides')
             x = self.view.x(position)
-            if x is None:
+            if x is None or label == '':
                 continue
             y = self.view.height + 5
             last_guide = (self._y_2nd_labels and label == lastlabel)

so, it would be nice to implement such a thing:

  1. Skip x guidelines when according labels are None.
  2. Draw x guidelines when according labels are empty strings.

The chart I got with this patch:

chart

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

No branches or pull requests

1 participant