Replies: 1 comment 1 reply
-
What I’m suggesting feels hacky, but what if you specify both a large
tickCount (like 1000) and tickMinStep=1. Does that produce what you want?
I think you are hoping for a tickMaxStep rather than a tickMinStep, but it
doesn’t seem to exist.
…On Tue, Aug 15, 2023 at 10:04 PM mcp292 ***@***.***> wrote:
MWE
<https://urldefense.com/v3/__https://altair-viz.github.io/gallery/simple_line_chart.html__;!!CzAuKJ42GuquVTTmVmPViYEvSg!JbLjcBDn-cSdWqI0Oo7AZewM8V12w-od-XOrHtP8Sscu_dSYr5_1YhuNwHJjUsUq_JQsBKEgwZU563lrK5lVI6Q$>
import altair as altimport numpy as npimport pandas as pd
x = np.arange(100)source = pd.DataFrame({
'x': x,
'f(x)': np.sin(x / 5)
})
alt.Chart(source).mark_line().encode(
x=alt.X('x').axis(tickMinStep=1),
y=alt.Y('f(x)').axis(tickMinStep=1)
).save("grid_step.png")
alt.Chart(source).mark_line().encode(
x=alt.X('x').axis(tickCount=100),
y=alt.Y('f(x)').axis(tickCount=100)
).save("grid_count.png")
Problem
I would like to make a grid line appear at every single unit.
When using tickMinStep=1 nothing happens:
[image: step]
<https://urldefense.com/v3/__https://user-images.githubusercontent.com/49123398/260827081-45afb8ec-60e7-45c4-8f1f-108865f69ace.png__;!!CzAuKJ42GuquVTTmVmPViYEvSg!JbLjcBDn-cSdWqI0Oo7AZewM8V12w-od-XOrHtP8Sscu_dSYr5_1YhuNwHJjUsUq_JQsBKEgwZU563lrAa_Rolw$>
But the documentation
<https://urldefense.com/v3/__https://altair-viz.github.io/user_guide/generated/core/altair.Axis.html__;!!CzAuKJ42GuquVTTmVmPViYEvSg!JbLjcBDn-cSdWqI0Oo7AZewM8V12w-od-XOrHtP8Sscu_dSYr5_1YhuNwHJjUsUq_JQsBKEgwZU563lrYBt2NHA$>
makes it seem this is exactly what I want:
The minimum desired step between axis ticks, in terms of scale domain
values. For example, a value of 1 indicates that ticks should not be less
than 1 unit apart. If tickMinStep is specified, the tickCount value will be
adjusted, if necessary, to enforce the minimum step value.
Using tickCount seems to work, but requires that you know the bounds of
your data a priori:
[image: count]
<https://urldefense.com/v3/__https://user-images.githubusercontent.com/49123398/260827161-89630d84-b1c3-4a26-a0f8-c3db6b96d984.png__;!!CzAuKJ42GuquVTTmVmPViYEvSg!JbLjcBDn-cSdWqI0Oo7AZewM8V12w-od-XOrHtP8Sscu_dSYr5_1YhuNwHJjUsUq_JQsBKEgwZU563lrl2aZ5C4$>
Notes
I would prefer to use tickMinStep or similar because I would like to
specify the interval/spacing of the gridlines, without knowing the domain
min and maxs.
This answer might be related, but I don't know how to translate it:
vega/vega#583 (comment)
<https://urldefense.com/v3/__https://github.com/vega/vega/issues/583*issuecomment-322338211__;Iw!!CzAuKJ42GuquVTTmVmPViYEvSg!JbLjcBDn-cSdWqI0Oo7AZewM8V12w-od-XOrHtP8Sscu_dSYr5_1YhuNwHJjUsUq_JQsBKEgwZU563lrQwi4Bcw$>
.
—
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/altair-viz/altair/discussions/3153__;!!CzAuKJ42GuquVTTmVmPViYEvSg!JbLjcBDn-cSdWqI0Oo7AZewM8V12w-od-XOrHtP8Sscu_dSYr5_1YhuNwHJjUsUq_JQsBKEgwZU563lrCJoc_mM$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ATXKWIFEIUOS5FH2ZKRBYY3XVPI3JANCNFSM6AAAAAA3RQT7IQ__;!!CzAuKJ42GuquVTTmVmPViYEvSg!JbLjcBDn-cSdWqI0Oo7AZewM8V12w-od-XOrHtP8Sscu_dSYr5_1YhuNwHJjUsUq_JQsBKEgwZU563lrGCzjuWg$>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
MWE
Problem
I would like to make a grid line appear at every single unit.
When using
tickMinStep=1
nothing happens:But the documentation makes it seem this is exactly what I want:
Using
tickCount
seems to work, but requires that you know the bounds of your data a priori:Notes
I would prefer to use
tickMinStep
or similar because I would like to specify the interval/spacing of the gridlines, without knowing the domain min and max.This answer might be related, but I don't know how to translate it: vega/vega#583 (comment).
Beta Was this translation helpful? Give feedback.
All reactions