2

I am aware of several patterns available in tikz patterns, such as vertical lines, crosshatch and etc. However, I need to create some tile pattern similar to that of checkerboard pattern in order to fill a bar chart. I was wondering how can I create such pattern and use it in my plots as simple as other available patterns?

It is noted that the existing checkerboard pattern is not a vector, so it looses quality after zooming.

\documentclass{standalone}
    \usepackage{pgfplots}
    \usepgfplotslibrary{groupplots}
    \usetikzlibrary{patterns}

    \begin{document}

        \definecolor{bblu}{HTML}{4F81BD}
        \definecolor{rred}{HTML}{C0504D}
        \definecolor{ggre}{HTML}{9BBB59}
        \definecolor{ppur}{HTML}{9F4C7C}
        \begin{tikzpicture}
            \begin{axis}[
                width  = 0.95*\textwidth,
                height = 8cm,
                major x tick style = transparent,
                ybar=2*\pgflinewidth,
                ymode=log,
                bar width=6pt,
                ylabel = {Running time (Minute)},
                symbolic x coords={Data 1,Data 2,Data 3},
                xtick = data,
                scaled y ticks = false,
                enlarge x limits=0.1,
                ylabel style={at={(0.04,0.5)}},
                x tick label style = {rotate=45},
                ymin=1,
                ymax=1500,
                legend cell align=left,
                legend style={
                        at={(.2,.75)},
                        anchor=south east,
                        column sep=.1ex,
                        nodes={scale=0.6, transform shape},
                }
            ]

                \addplot
                [area legend, style={cyan,fill=cyan,mark=none}]
                    coordinates {(Data 1, 22) (Data 2, 22) (Data 3, 22)};

                \addplot
                [area legend, style={rred,fill=rred,mark=none, pattern=checkerboard, pattern color=rred}]
                    coordinates {(Data 1, 22) (Data 2, 22) (Data 3, 22)};

                \addplot
                [area legend, style={ggre,fill=ggre,mark=none, pattern=vertical lines, pattern color=ggre}]
                    coordinates {(Data 1, 0.1) (Data 2, 0.1) (Data 3, 0.1)};

                \legend{Alg 1,Alg 2,Alg 3}
            \end{axis}
        \end{tikzpicture}

    \end{document}

This is what I get after zooming:

enter image description here

orezvani
  • 747
  • 1
    Manual section 104 - Patterns explains the use of command \pgfdeclarepatternformonly with some examples. These patterns can be used if pgfplots as is shown in http://tex.stackexchange.com/a/229251/1952 – Ignasi May 31 '16 at 17:57
  • What's a pile pattern? – cfr Jun 01 '16 at 01:14
  • 1
    @cfr tile pattern, similar to checkerboard pattern. – orezvani Jun 01 '16 at 01:19
  • @emab Oh, right. There's a typo in the question. I thought maybe it had something to do with carpets. (Couldn't think of any other pile patterns which might be suitable for turning into TikZ patterns.) – cfr Jun 01 '16 at 01:37
  • 1
    @cfr Yes, thanks for pointing it out. I fixed it and added more details to the question. – orezvani Jun 01 '16 at 01:38
  • I don't understand about its not being a vector. Could you provide an example of how you want to use this for testing? You are more likely to get effective help that way. – cfr Jun 01 '16 at 01:44
  • For example, I filled a rectangle with a magenta-coloured checkerboard and zoomed in to the maximum my PDF viewer supports (1,600%) and I don't see any loss of quality in the result. Of course, the pattern isn't a vector. But nor is it bitmap. Rather it isn't an image at all so this is just irrelevant. Something like a category mistake, I suppose. – cfr Jun 01 '16 at 01:49
  • @cfr Interesting, I used in the example mentioned in my question and posted a screenshot. It does not look like a vector, as it looses quality after zooming. – orezvani Jun 01 '16 at 02:05
  • I don't get that result from your code. How are you compiling? I'm using pdfLaTeX. – cfr Jun 01 '16 at 02:09
  • See this. That's a maximum zoom on the PDF produced from your code with pdfLaTeX. That is, at 1,600%, I don't get the fuzziness you report at less than one quarter of the magnification. – cfr Jun 01 '16 at 02:11
  • @cfr I tried it with a different pdf viewer and it worked perfectly. It seems to be pdf viewer problem. But I don't know why this pdf viewer (gnome document viewer) shows vertical lines as vector, but checkerboard fuzzy. – orezvani Jun 01 '16 at 02:56
  • What's it based on? Okular is fine and that's Poppler-based. I would assume Evince would be similar. Not sure beyond that. Or could they be using different versions of the libraries or something? I don't know anything about gnome's document viewer. (I thought Gnome used Evince.) – cfr Jun 01 '16 at 03:05
  • It's actually Evince. But I don't know what is it based on. I tried it with Foxreader and acrobat and they worked fine. – orezvani Jun 01 '16 at 03:36
  • 4
    I'm voting to close this question because using checkerboard pattern was suitable to solve the problem (after it was clarified that it is a vector pattern). – Stefan Pinnow Dec 11 '16 at 12:19

0 Answers0