I’m trying to find a way to change the tick interval on a chart axis. I’ve tried in Line Plot and also Line Plot (Plotly), but I just get a thick black line with labels overlapping - see image below
The labels are YYYY-WW (year-week number) but in string format.
As an alternative to experimenting with this as a string, I tried to put them back to date format but can’t find a way to do this. They have to be week numbers because I import multiple datasets that I can only match on a weekly basis because they have different day-dates. I can’t figure out how to reverse the process I use to get YYYY-WW from actual dates, which is:: Extract date&time fields (to get Y & W) >> Number to string (as prep for next step) >>> string manipulation (to concatenate to get YYYY-WW).
From other charts I have, I think Line Plot will handle tick spacing if it’s in date format.
A solution either way (for date or string labels) would be much appreciated.
Below follows a possible solution for strings.
I don’t know how to solve this purely with the Line Plot node configuration. However, the line plot simply plots the points as they appear in the table going top to bottom. In contrast with a scatter plot, it does not care what the x-labels are. So, if you want to prevent label overlap by having fewer labels, as a workaround you can simply replace unwanted labels by empty strings in the table. For example:
If we want fewer labels on the X-axis, we can insert a Java Snippet into the workflow:
With the following configuration:
This yields the following table:
Which results in a plot with fewer tick labels:
Just increase the “2” in the Java Snippet code with higher numbers if you want even fewer labels to appear.
Thank you for your help, and for your clear explanation.
That’s worked for me, I just need to play around with it a bit more to try to fit in more than annual ticks
Maybe Knime can add this to their line plot nodes?
I’d looked at this before I posted my plea for help. With my limited programming skills, I wasn’t able to find a way to make this work easily and it looked like it was going to take me a lot of time to figure out how to work through CSS properly. Aswin’s 1-line solution has worked so I’ll go with that, and perhaps experiment with CSS when time permits.
I see. Glad to hear that worked for you. Also to mention there is already a ticket to enhance labeling options on plots and I have noted your request there.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.