SetFillStyle(2001) does not work with .eps, .ps, .pdf

Hello experts,

Anybody know why the hatches style does not work with .eps?
well I need this extension of the plots for including in a latex file and I want to compile with latex instead of pdflatex.
Did I do any wrong?

{
  TCanvas c("c","c");
  TH1F* h = new TH1F("h","h",50,-4,4);
  h->Sumw2();
  h->FillRandom("gaus",2000);
  h->SetLineColor(kRed);
  h->SetFillStyle(2001);
  h->SetFillColor(kYellow);
  h->Draw("E2HIST");
  c.SaveAs("h.ps");
  c.SaveAs("h.eps");
  c.SaveAs("h.pdf");
  c.SaveAs("h.gif");
  c.SaveAs("h.png");
  c.SaveAs("h.jpg");
  c.SaveAs("h.root");
  c.SaveAs("h.C");
}

My version of ROOT is 5.28.00b and I have tryed in two platforms: linuxx8664 and macosx64.
Thanks in advance.

Actually, what I get are three “types of pictures” which look significantly different (“fill style” 2001):

  1. h.pdf -> “hatch style”
  2. h.ps, h.eps -> “solid style” (“no hatch”)
  3. h.gif, h.jpg, h.png, h.C, h.root -> not "filled"
    If I “h->SetFillStyle(3013);”, it reduces to two “types”:
  4. h.pdf, h.gif, h.jpg, h.png, h.C, h.root -> “hatch style”
  5. h.ps, h.eps -> “solid style” (“no hatch”)
    So, maybe one needs to find a magic “fill style” value?
    See http://root.cern.ch/root/html/TAttFill.html for details.

It is true that root.cern.ch/root/html/TAttFill.html gives the style 2001 as valid.
But then the example shows only 3xxx type fill style. I’ll check the validity of the 2xxx style.
It could be that they are not vlid (in that case I’ ll update the doc) .
I would recommend to use the 3xxx style which work the same in all output style.

In this case, please note that at least “3013” and “3014” fail the test (ps/eps is different from pdf).
Just for fun I checked “3015” and “3025” and they both work well.

I’ll check Monday …

I disagree they look the same (I just ran the test macro here root.cern.ch/root/html/TAttFill.html#F2)
Have a good week end.

Well I think that I misunderstood what ‘hatch style’ means, the fact is that I want
that the error bars be rectangles with a filling color (in this case yellow), I dont care about the pattern of filled,
and that the remain of the histogram area be unfilled with any color (any of the results given by .gif, .png, .jpeg, .root).

Is this possible? I mean for .eps.

If not, I think that I would use the .png for my histos and to change the old .eps files to .pdf, and compile with pdflatex. :angry:

Thanks.

I’ll use your macro as example. But I 'll do that Monday …
Have a good week end.

Try to “SaveAs” the canvas as “.ps” / “.eps” and then see the file.


Of course I did that … [color=#FF0000]they are the same ![/color]
Please when you have a new question create a new thread, avoid polluting an existing thread this makes some noise which hide the original question.

here they are
Patterns.ps (35.1 KB)
Patterns.pdf (18.6 KB)

So your original problem is that you want to get this as “.eps”?
If yes, then I don’t know how to do this, sorry.


As I said, 2001 fill style has a problem. Again, as I said I will check that Monday.
The 3001 fill style are fine and look the same in PS and PDF.
Can we stop here right now ? Thanks …

I get the same “Patterns.ps” and “Patterns.pdf”, but they look different on my screen (the “.pdf” looks correctly, the “.ps” looks like in my previous post - some patterns are just “black”, even if I look at them magnified 10x in “gv”).

gv is buggy. It is well known: root.cern.ch/drupal/faq#n562
On my Mac Book they look EXACTLY the same… If I print they look EXACTLY the same.

O.K. Sorry. I’ve forgotten about it completely (now I remember that I’d already faced this problem some years ago, and I’d known the solution, too).
Switching “State->Antialias” off in “gv” helped immediately.

[quote=“Pepe Le Pew”]So your original problem is that you want to get this as “.eps”?
[/quote]
yes!

I’ll learn to live with this.

Well, I’ve found I do know how to do this after all. :mrgreen:

{
  TCanvas c("c","c");
  TH1F* h = new TH1F("h","h",50,-4,4);
  h->Sumw2();
  h->FillRandom("gaus",2000);
  h->SetMarkerSize(0);
  h->SetLineColor(kRed);
  h->SetFillColor(kYellow);
  h->DrawClone("E2");
  h->SetFillColor(kWhite);
  h->Draw("HIST SAME");
  h->SetMarkerSize(1);
  c.SaveAs("h.ps");
  c.SaveAs("h.eps");
  c.SaveAs("h.pdf");
  c.SaveAs("h.gif");
  c.SaveAs("h.png");
  c.SaveAs("h.jpg");
  c.SaveAs("h.root");
  c.SaveAs("h.C");
}

It seems that you rock with root brother,

thank you!

Pepe Le Pew solution does not address the 2001 fill style issue.
My guess is that 2001 was kept for some compatibility issue. So I t should be fixed.
I had not time to check yet … I 'll let you know