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

Latex support in labels. #56

Open
dineshadepu opened this issue Nov 29, 2019 · 1 comment
Open

Latex support in labels. #56

dineshadepu opened this issue Nov 29, 2019 · 1 comment

Comments

@dineshadepu
Copy link

Hello,

First, thank you for the crate. Very helpful.

I am trying to add symbols in the labels, like, nano, or $\lambda$ symbols.

Is this supported currently?

I tried doing this,

    let mut fg = Figure::new();
    fg.axes2d()
        .set_x_label("Normal contact displacement ($$\lambda$$ nano m)", &[])
        .set_y_label("Normal contact force (kN)", &[])
        .set_x_range(Fix(0.), Fix(400.))
        .set_y_range(Fix(0.), Fix(12.));

But it fails.

@SiegeLord
Copy link
Owner

So the story for this is pretty bad on gnuplot's side. The only "official" way I could find for now is to use the "epslatex" terminal (ideally with the 'standalone' option), which lets you write code like this:

use gnuplot::*;

fn main()
{
  let mut fg = Figure::new();
  fg.axes2d().set_title(r"$\\lambda$", &[]);
  fg.set_terminal("epslatex standalone", "output.tex");
  fg.show().unwrap();
}

Then, you run that program you get a .ps and .tex files that you can pass through pdflatex to get the final pdf output. It's hardly ideal.

If all you need is some symbols and super- and sub-scripts, then at least as of 1d9866d it should work to do things like "λ^2", i.e. use unicode + caret/underscores.

I'll see what I can do to make this better.

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

2 participants