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

Add legends to cetz.plot #354

Closed
Kreijstal opened this issue Nov 25, 2023 · 4 comments · Fixed by #355
Closed

Add legends to cetz.plot #354

Kreijstal opened this issue Nov 25, 2023 · 4 comments · Fixed by #355
Labels
question ❔ Further information is requested

Comments

@Kreijstal
Copy link
Contributor

Just like matplotlib! Teachers will give you negative points if your plots don't have legends.

@johannes-wolf johannes-wolf added the question ❔ Further information is requested label Nov 25, 2023
@johannes-wolf
Copy link
Member

It's already on 0.2.0.

#cetz.canvas({
  import cetz.draw: *

  plot.plot(size: (8,6), {
    plot.add(domain: (0, 2*calc.pi), calc.sin, label: $ sin x $)
    plot.add(domain: (0, 2*calc.pi), calc.cos, label: $ cos x $)
  })
})

grafik

@Kreijstal
Copy link
Contributor Author

I guess I'll have to wait till next release in
https://github.com/typst/packages/

@dscso
Copy link
Contributor

dscso commented Nov 25, 2023

I tried this code in 2.0 unfortunately the grid is broken on the x side. Maybe this comment helps as a bug report

canvas({
    import draw: *

    plot.plot(
        size: (8,6),
        x-grid: true,
        y-grid: true,
        {
            plot.add(domain: (0, 2*calc.pi), calc.sin, label: $ sin x $)
            plot.add(domain: (0, 2*calc.pi), calc.cos, label: $ cos x $)
        }
    )
})
image

@johannes-wolf
Copy link
Member

That also got fixed but not yet merged. The fix should be in the bar-/columnchart PR: #337.

@johannes-wolf johannes-wolf linked a pull request Nov 25, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question ❔ Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants