0

Here is my MWE:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\pgfplotsset{compat=1.11, width=8cm, height=8cm,
    /pgfplots/ybar legend/.style={
        /pgfplots/legend image code/.code={%
            \draw [#1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);},
    },
}

\begin{document}

\pgfplotstableread[col sep=comma]{
    
    No. of jobs,    G-1,    G-2,    FAIR,   Capacity
    0,              0,      0,      0,      0
    5,              28409,  25456,  45105,  49906
    10,             44501,  39523,  58079,  59405
    15,             58312,  48223,  74509,  87619
    20,             65590,  58233,  89123,  92960
    25,             0,      0,      0,      0
    
}\PageRanka
%\pgfplotstablesave[skip rows between index={0}{2}]{\PageRanka}{test.dat}
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=.70,xscale=.70]

\begin{axis}[
cycle list={{orange,thick,mark=square*}, {green,thick,mark=triangle*}, {yellow,thick,mark=otimes*}, {blue,thick,mark=diamond*}},
ymin=00000, ymax=100000,
%ytick=data,
ytick={00000,20000,40000,60000,80000,100000},
bar width=0.35cm, %width=1\textwidth,
enlarge x limits=0.00,
enlarge y limits={0.00, upper},
xtick pos=left,ytick pos=lower,
legend style={at={(1,1.1)}, anchor=south east, legend columns=-1},
grid=major,
xlabel={No. of jobs},
ylabel={Total energy consumption ($ J $)},
xticklabels from table={\PageRanka}{No. of jobs},
xtick=data,
]

\pgfplotsinvokeforeach {1,...,4}{
    \addplot table [x expr=\coordindex, y index=#1] {\PageRanka};
}
\legend{G-1,G-2,FAIR,CS}
\end{axis}
\end{tikzpicture}


\end{document}

and here is the output:

enter image description here

Question: I want to skip line plots from co-ordinates 0 to 5 and from 20 to 25. How to do that?

0

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\pgfplotsset{compat=1.11, width=8cm, height=8cm,
    /pgfplots/ybar legend/.style={
        /pgfplots/legend image code/.code={%
            \draw [#1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);},
    },
}

\begin{document}
    
    \pgfplotstableread[col sep=comma]{
        
        No. of jobs,    G-1,    G-2,    FAIR,   Capacity
        0,              0,      0,      0,      0
        5,              28409,  25456,  45105,  49906
        10,             44501,  39523,  58079,  59405
        15,             58312,  48223,  74509,  87619
        20,             65590,  58233,  89123,  92960
        25,             0,      0,      0,      0
        
    }\PageRanka
    %\pgfplotstablesave[skip rows between index={0}{2}]{\PageRanka}{test.dat}
    \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=.70,xscale=.70]
    
    \begin{axis}[
    cycle list={{orange,thick,mark=square*}, {green,thick,mark=triangle*}, {yellow,thick,mark=otimes*}, {blue,thick,mark=diamond*}},
    ymin=00000, ymax=100000,
    %ytick=data,
    ytick={00000,20000,40000,60000,80000,100000},
    bar width=0.35cm, %width=1\textwidth,
    enlarge x limits=0.00,
    enlarge y limits={0.00, upper},
    xtick pos=left,ytick pos=lower,
    legend style={at={(1,1.1)}, anchor=south east, legend columns=-1},
    grid=major,
    xlabel={No. of jobs},
    ylabel={Total energy consumption ($ J $)},
    xticklabels from table={\PageRanka}{No. of jobs},
    xtick=data,skip coords between index={0}{1},
    skip coords between index={4}{5},
    ]

    \pgfplotsinvokeforeach {1,...,4}{
        \addplot table [x expr=\coordindex, y index=#1] {\PageRanka};
    }
    \legend{G-1,G-2,FAIR,CS}
    \end{axis}
    \end{tikzpicture}
    
    
\end{document}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.