Jak dodać linię pomocy i kolor tła przez tikz

Wei Li 05/10/2018. 1 answers, 50 views
pgfplots tikz-styles

każdy:

Chcę użyć tikz, aby narysować taką postać:

wprowadź opis obrazu tutaj

Ale nie wiem, jak add help line i background color Więc po prostu otrzymuję tę postać: wprowadź opis obrazu tutaj

Jak mogę zmienić mój kod? ktoś może mi pomóc?

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{figure}
    \centering
    \begin{tikzpicture}
    \begin{axis}[
        xtick={0,40,...,160},
        ymin=0,
        ymax=12,
        xmin=0,
        xmax=180,
        grid style=dashed,
        yticklabel style = {font=\tiny},
        xticklabel style = {font=\tiny},
        legend style={draw=none,font=\tiny,legend pos=south east,cells={anchor=west}}
    ]

        \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (40,8.35)
        (60,7.87)
        (80,7.51)
        (100,7.32)
        (120,7.15)
        (140,7.02)
        (160,6.97)
        };
        \addlegendentry{S$_1+$ S$_2$= 200}

        \addplot[
        color=red,
        mark=square,
        ]
        coordinates {
        (40,9.54)
        (60,9.35)
        (80,8.77)
        (100,8.81)
        (120,8.66)
        (140,8.29)
        (160,8.59)
        };
        \addlegendentry{S$_1+$ S$_2$= 300}

    \end{axis}
    \end{tikzpicture}
  \caption{Comparison of S}
  \label{step_decay_test_performance}
\end{figure}

\end{document} 

1 Answers


Torbjørn T. 05/10/2018.

grid style , ale nie aktywowałeś grid . Dodaj grid do opcji axis . Aby ustawić kolor tła, axis background/.style={fill=blue!10} . Jeśli chcesz, aby legenda miała ten sam kolor, dodaj to samo fill do legend style .

wprowadź opis obrazu tutaj

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{figure}
    \centering
    \begin{tikzpicture}
    \begin{axis}[
        xtick={0,40,...,160},
        ymin=0,
        ymax=12,
        xmin=0,
        xmax=180,
        grid, % <---- added
        grid style=dashed,
        yticklabel style = {font=\tiny},
        xticklabel style = {font=\tiny},
        legend style={draw=none,font=\tiny,legend pos=south east,cells={anchor=west}},
        axis background/.style={fill=blue!10} % <--- added
    ]

        \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (40,8.35)
        (60,7.87)
        (80,7.51)
        (100,7.32)
        (120,7.15)
        (140,7.02)
        (160,6.97)
        };
        \addlegendentry{S$_1+$ S$_2$= 200}

        \addplot[
        color=red,
        mark=square,
        ]
        coordinates {
        (40,9.54)
        (60,9.35)
        (80,8.77)
        (100,8.81)
        (120,8.66)
        (140,8.29)
        (160,8.59)
        };
        \addlegendentry{S$_1+$ S$_2$= 300}

    \end{axis}
    \end{tikzpicture}
  \caption{Comparison of S}
  \label{step_decay_test_performance}
\end{figure}

\end{document} 

HighResolutionMusic.com - Download Hi-Res Songs

1 The Chainsmokers

Beach House flac

The Chainsmokers. 2018. Writer: Andrew Taggart.
2 Anne-Marie

Rewrite The Stars flac

Anne-Marie. 2018. Writer: Benj Pasek;Justin Paul.
3 (G)I-DLE

POP/STARS flac

(G)I-DLE. 2018. Writer: Riot Music Team;Harloe.
4 Ariana Grande

​Thank U, Next flac

Ariana Grande. 2018. Writer: Crazy Mike;Scootie;Victoria Monét;Tayla Parx;TBHits;Ariana Grande.
5 Clean Bandit

Baby flac

Clean Bandit. 2018. Writer: Jack Patterson;Kamille;Jason Evigan;Matthew Knott;Marina;Luis Fonsi.
6 BTS

Waste It On Me flac

BTS. 2018. Writer: Steve Aoki;Jeff Halavacs;Ryan Ogren;Michael Gazzo;Nate Cyphert;Sean Foreman;RM.
7 Diplo

Close To Me flac

Diplo. 2018. Writer: Ellie Goulding;Savan Kotecha;Peter Svensson;Ilya;Swae Lee;Diplo.
8 Imagine Dragons

Bad Liar flac

Imagine Dragons. 2018. Writer: Jorgen Odegard;Daniel Platzman;Ben McKee;Wayne Sermon;Aja Volkman;Dan Reynolds.
9 Rita Ora

Cashmere flac

Rita Ora. 2018. Writer: Sean Douglas;Lindy Robbins.
10 Backstreet Boys

Chances flac

Backstreet Boys. 2018.
11 BlackPink

Kiss And Make Up flac

BlackPink. 2018. Writer: Soke;Kny Factory;Billboard;Chelcee Grimes;Teddy Park;Marc Vincent;Dua Lipa.
12 Billie Eilish

When The Party's Over flac

Billie Eilish. 2018. Writer: Billie Eilish;FINNEAS.
13 Nicki Minaj

No Candle No Light flac

Nicki Minaj. 2018. Writer: Denisia “Blu June” Andrews;Kathryn Ostenberg;Brittany "Chi" Coney;Brian Lee;TJ Routon;Tushar Apte;ZAYN;Nicki Minaj.
14 Fitz And The Tantrums

HandClap flac

Fitz And The Tantrums. 2017. Writer: Fitz And The Tantrums;Eric Frederic;Sam Hollander.
15 Little Mix

Woman Like Me flac

Little Mix. 2018. Writer: Nicki Minaj;Steve Mac;Ed Sheeran;Jess Glynne.
16 Brooks

Limbo flac

Brooks. 2018.
17 Zara Larsson

Ruin My Life flac

Zara Larsson. 2018. Writer: Delacey;Michael Pollack;Stefan Johnson;Jordan Johnson;Sermstyle;Jackson Foote.
18 Billie Eilish

Come Out And Play flac

Billie Eilish. 2018. Writer: FINNEAS;Billie Eilish.
19 Kelly Clarkson

Never Enough flac

Kelly Clarkson. 2018. Writer: Benj Pasek;Justin Paul.
20 Cher Lloyd

None Of My Business flac

Cher Lloyd. 2018. Writer: ​iamBADDLUCK;Alexsej Vlasenko;Kate Morgan;Henrik Meinke;Jonas Kalisch;Jeremy Chacon.

Related questions

Hot questions

Language

Popular Tags