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

BarChart Not Working Properly #173

Closed
chelseas opened this issue May 18, 2021 · 6 comments
Closed

BarChart Not Working Properly #173

chelseas opened this issue May 18, 2021 · 6 comments

Comments

@chelseas
Copy link

fig = PGFPlots.Axis()
push!(fig, PGFPlots.Plots.BarChart([1,2]))
PGFPlots.save("test_bar.pdf", fig)

produces
image

@mirkobunse
Copy link
Contributor

mirkobunse commented May 18, 2021

Looks like PGFPlots does not add the ybar option to the axis:

julia> println(tikzCode(fig))

\begin{axis}
\addplot+ coordinates {
  (1, 1)
  (2, 2)
};
\end{axis}

@mykelk
Copy link
Member

mykelk commented May 18, 2021

You can try this:
image
The issue with the original code is that fig = PGFPlots.Axis() creates an axis with no properties, and to get this kind of axis plot, the ybar property of the axis needs to be set.

@chelseas
Copy link
Author

The problem with this solution is that I would like to make a grouped bar chart by pushing multiple BarCharts onto a single Axis. One solution is to manually set ybar in the latex code but is there another solution?

@mykelk
Copy link
Member

mykelk commented May 18, 2021

You can create the Axis using my method with the first bar chart, and then push on additional bar charts to that axis.

@chelseas
Copy link
Author

Your method returns an object of type
PGFPlots.Plots.BarChart
but I'm guessing perhaps there's some way to extract the associated Axis object?

@mykelk
Copy link
Member

mykelk commented May 19, 2021

I think you can do this:
image

@mykelk mykelk closed this as completed Oct 26, 2021
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

3 participants