Not able to create two Y axes with the same scale and number of ticks
See original GitHub issueI’m creating a stacked chart where bars represent electricity consumption and lines represent outside temperature:
I’m trying to achieve a chart where the temperature labels would align with the grid lines rendered by the consumption data as they do on the Y axis on the left. But as it can be seen from the pic above, both the number of ticks and their position is different from the ones in the consumption axis. This is something that seems like a bug, as I’m using the same value (5) for the numberOfTicks
prop. But is this just a feature that’s caused by the underlying d3 library? Please help me to understand how the Y axis scaling works 🙏 😄
Below a simplified code:
<View
style={{
height: 300,
flexDirection: 'row',
}}>
<YAxis
data={consumptionData}
style={{ marginBottom: 20 }}
numberOfTicks={5}
/>
<View style={{ flex: 1 }}>
<BarChart
style={{ flex: 1 }}
numberOfTicks={5}
data={consumptionData}>
<Grid />
</BarChart>
<LineChart
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 20,
}}
data={temperatureData}
numberOfTicks={5}
/>
<XAxis style={{ height: 20 }} data={consumptionData} />
</View>
<YAxis
data={temperatureData}
style={{ marginBottom: 20 }}
numberOfTicks={5}
/>
</View>
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
I would like to have two y-axis and corresponding y-axis ticks ...
I have two variables which I normalized by a constant and plotted on y axis (left) against an independent variable on x-axis. Both...
Read more >trouble aligning ticks for matplotlib twinx axes - Stack Overflow
The y-axes have different scales, but I want the ticks and grid to be aligned. I am pulling the data from excel files,...
Read more >Y-axis tick marks not aligning when using two y-axes in tw line
First time poster here, so please bear with me. I'm using this data: * Example generated by -dataex-. To install: ssc install dataex...
Read more >Why not to use two axes, and what to use instead
We believe that charts with two different y-axes make it hard for most people to intuitively make right statements about two data series....
Read more >Customize X-axis and Y-axis properties - Power BI
In this tutorial, you'll learn many different ways to customize the X-axis and Y-axis of your visuals. Not all visuals have axes.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @ajacquierbret for insights and tips and @JesperLekland for your great work with this library. And what a coincidence that we’re building same kind of charts 😄
I’ll try to play with the parameters and also try the axis label formatting trick. Maybe I’ll also have to study a bit d3 😬 😅
Back from the holidays… I’ll close this issue for now and try these tips when I’ll have again time to investigate this issue. Once again, thanks for help and this great library 💎