How do I color the graph in datavisualization? The Next CEO of Stack OverflowHow to color the area under a curve using tikz datavisualization?Plotting my chart incorrectly in tikzColor the faces of a graphlatex graph points tikzHow to color the area under a curve using tikz datavisualization?How to prevent rounded and duplicated tick labels in pgfplots with fixed precision?datavisualization and csv dataTikz and exponential style tick labelNeural Network GraphHow to write under graph in latexStyles in datavisualization legendsI want to color a graph

Why the last AS PATH item always is `I` or `?`?

"Eavesdropping" vs "Listen in on"

What day is it again?

Can Sneak Attack be used when hitting with an improvised weapon?

Is it okay to majorly distort historical facts while writing a fiction story?

Is it ever safe to open a suspicious HTML file (e.g. email attachment)?

From jafe to El-Guest

Is it correct to say moon starry nights?

Expressing the idea of having a very busy time

IC has pull-down resistors on SMBus lines?

Reference request: Grassmannian and Plucker coordinates in type B, C, D

New carbon wheel brake pads after use on aluminum wheel?

What connection does MS Office have to Netscape Navigator?

Does Germany produce more waste than the US?

Prepend last line of stdin to entire stdin

Can someone explain this formula for calculating Manhattan distance?

Traduction de « Life is a roller coaster »

What flight has the highest ratio of timezone difference to flight time?

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

What was the first Unix version to run on a microcomputer?

Is there a reasonable and studied concept of reduction between regular languages?

Are the names of these months realistic?

Aggressive Under-Indexing and no data for missing index

How to avoid supervisors with prejudiced views?



How do I color the graph in datavisualization?



The Next CEO of Stack OverflowHow to color the area under a curve using tikz datavisualization?Plotting my chart incorrectly in tikzColor the faces of a graphlatex graph points tikzHow to color the area under a curve using tikz datavisualization?How to prevent rounded and duplicated tick labels in pgfplots with fixed precision?datavisualization and csv dataTikz and exponential style tick labelNeural Network GraphHow to write under graph in latexStyles in datavisualization legendsI want to color a graph










4















MWE:



documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarydatavisualization
usetikzlibraryarrows,calc
usetikzlibraryshapes,positioning
usetikzlibrarydecorations.markings
usetikzlibrarydatavisualization.formats.functions
defmytypesetter#1
pgfmathparse#1/pi
pgfkeys/pgf/number format/precision=2
pgfmathroundtozerofillpgfmathresult
pgfmathifisintpgfmathresult
pgfmathprintnumberpgfmathresult$pi$

pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


begindocument


begintikzpicture[>=latex]
datavisualization [
school book axes, %scientific axes=clean,
all axes=,
x axis=
label=$omega t$,
ticks=
step=(pi/2),
tick typesetter/.code=mytypesetter##1,
,
y axis=
label=$v$,
ticks=none,
,
style sheet=strong colors,
style sheet=vary dashing,
visualize as smooth line/.list=voltage,
voltage=label in legend=text=$v$,
]
data [set=voltage, format=function]
var x : interval [0:2*pi] samples 100;
func y = 2*sin(value x r);
;
endtikzpicture
enddocument


But this is what I want



enter image description here.



How do I get this graph from my source code without using axis environment?










share|improve this question
























  • See tex.stackexchange.com/a/228265/121799

    – marmot
    Mar 24 at 1:02











  • @marmot, I had seen but could not adapt to my source code.

    – Özgür
    Mar 24 at 1:27











  • I quickly tried and could at least shade the curve. Most likely one can also draw the vertical lines. However, why do you not want to use JouleV's nice solution or pgfplots?

    – marmot
    Mar 24 at 1:30











  • It's a really nice solution. But I've got 50+ pages of graphics. If I can't find the right solution, of course I will.

    – Özgür
    Mar 24 at 1:36















4















MWE:



documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarydatavisualization
usetikzlibraryarrows,calc
usetikzlibraryshapes,positioning
usetikzlibrarydecorations.markings
usetikzlibrarydatavisualization.formats.functions
defmytypesetter#1
pgfmathparse#1/pi
pgfkeys/pgf/number format/precision=2
pgfmathroundtozerofillpgfmathresult
pgfmathifisintpgfmathresult
pgfmathprintnumberpgfmathresult$pi$

pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


begindocument


begintikzpicture[>=latex]
datavisualization [
school book axes, %scientific axes=clean,
all axes=,
x axis=
label=$omega t$,
ticks=
step=(pi/2),
tick typesetter/.code=mytypesetter##1,
,
y axis=
label=$v$,
ticks=none,
,
style sheet=strong colors,
style sheet=vary dashing,
visualize as smooth line/.list=voltage,
voltage=label in legend=text=$v$,
]
data [set=voltage, format=function]
var x : interval [0:2*pi] samples 100;
func y = 2*sin(value x r);
;
endtikzpicture
enddocument


But this is what I want



enter image description here.



How do I get this graph from my source code without using axis environment?










share|improve this question
























  • See tex.stackexchange.com/a/228265/121799

    – marmot
    Mar 24 at 1:02











  • @marmot, I had seen but could not adapt to my source code.

    – Özgür
    Mar 24 at 1:27











  • I quickly tried and could at least shade the curve. Most likely one can also draw the vertical lines. However, why do you not want to use JouleV's nice solution or pgfplots?

    – marmot
    Mar 24 at 1:30











  • It's a really nice solution. But I've got 50+ pages of graphics. If I can't find the right solution, of course I will.

    – Özgür
    Mar 24 at 1:36













4












4








4








MWE:



documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarydatavisualization
usetikzlibraryarrows,calc
usetikzlibraryshapes,positioning
usetikzlibrarydecorations.markings
usetikzlibrarydatavisualization.formats.functions
defmytypesetter#1
pgfmathparse#1/pi
pgfkeys/pgf/number format/precision=2
pgfmathroundtozerofillpgfmathresult
pgfmathifisintpgfmathresult
pgfmathprintnumberpgfmathresult$pi$

pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


begindocument


begintikzpicture[>=latex]
datavisualization [
school book axes, %scientific axes=clean,
all axes=,
x axis=
label=$omega t$,
ticks=
step=(pi/2),
tick typesetter/.code=mytypesetter##1,
,
y axis=
label=$v$,
ticks=none,
,
style sheet=strong colors,
style sheet=vary dashing,
visualize as smooth line/.list=voltage,
voltage=label in legend=text=$v$,
]
data [set=voltage, format=function]
var x : interval [0:2*pi] samples 100;
func y = 2*sin(value x r);
;
endtikzpicture
enddocument


But this is what I want



enter image description here.



How do I get this graph from my source code without using axis environment?










share|improve this question
















MWE:



documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarydatavisualization
usetikzlibraryarrows,calc
usetikzlibraryshapes,positioning
usetikzlibrarydecorations.markings
usetikzlibrarydatavisualization.formats.functions
defmytypesetter#1
pgfmathparse#1/pi
pgfkeys/pgf/number format/precision=2
pgfmathroundtozerofillpgfmathresult
pgfmathifisintpgfmathresult
pgfmathprintnumberpgfmathresult$pi$

pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


begindocument


begintikzpicture[>=latex]
datavisualization [
school book axes, %scientific axes=clean,
all axes=,
x axis=
label=$omega t$,
ticks=
step=(pi/2),
tick typesetter/.code=mytypesetter##1,
,
y axis=
label=$v$,
ticks=none,
,
style sheet=strong colors,
style sheet=vary dashing,
visualize as smooth line/.list=voltage,
voltage=label in legend=text=$v$,
]
data [set=voltage, format=function]
var x : interval [0:2*pi] samples 100;
func y = 2*sin(value x r);
;
endtikzpicture
enddocument


But this is what I want



enter image description here.



How do I get this graph from my source code without using axis environment?







tikz-pgf diagrams






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 16:00









JouleV

9,39322256




9,39322256










asked Mar 23 at 20:07









ÖzgürÖzgür

1,4611020




1,4611020












  • See tex.stackexchange.com/a/228265/121799

    – marmot
    Mar 24 at 1:02











  • @marmot, I had seen but could not adapt to my source code.

    – Özgür
    Mar 24 at 1:27











  • I quickly tried and could at least shade the curve. Most likely one can also draw the vertical lines. However, why do you not want to use JouleV's nice solution or pgfplots?

    – marmot
    Mar 24 at 1:30











  • It's a really nice solution. But I've got 50+ pages of graphics. If I can't find the right solution, of course I will.

    – Özgür
    Mar 24 at 1:36

















  • See tex.stackexchange.com/a/228265/121799

    – marmot
    Mar 24 at 1:02











  • @marmot, I had seen but could not adapt to my source code.

    – Özgür
    Mar 24 at 1:27











  • I quickly tried and could at least shade the curve. Most likely one can also draw the vertical lines. However, why do you not want to use JouleV's nice solution or pgfplots?

    – marmot
    Mar 24 at 1:30











  • It's a really nice solution. But I've got 50+ pages of graphics. If I can't find the right solution, of course I will.

    – Özgür
    Mar 24 at 1:36
















See tex.stackexchange.com/a/228265/121799

– marmot
Mar 24 at 1:02





See tex.stackexchange.com/a/228265/121799

– marmot
Mar 24 at 1:02













@marmot, I had seen but could not adapt to my source code.

– Özgür
Mar 24 at 1:27





@marmot, I had seen but could not adapt to my source code.

– Özgür
Mar 24 at 1:27













I quickly tried and could at least shade the curve. Most likely one can also draw the vertical lines. However, why do you not want to use JouleV's nice solution or pgfplots?

– marmot
Mar 24 at 1:30





I quickly tried and could at least shade the curve. Most likely one can also draw the vertical lines. However, why do you not want to use JouleV's nice solution or pgfplots?

– marmot
Mar 24 at 1:30













It's a really nice solution. But I've got 50+ pages of graphics. If I can't find the right solution, of course I will.

– Özgür
Mar 24 at 1:36





It's a really nice solution. But I've got 50+ pages of graphics. If I can't find the right solution, of course I will.

– Özgür
Mar 24 at 1:36










2 Answers
2






active

oldest

votes


















4














Nothing prevents you from adding the fills on the background.



documentclass[tikz,border=10pt]standalone
usetikzlibrarydatavisualization
usetikzlibrarydatavisualization.formats.functions
usetikzlibrarypatterns,backgrounds
defmytypesetter#1
pgfmathparse#1/pi
pgfkeys/pgf/number format/precision=2
pgfmathroundtozerofillpgfmathresult
pgfmathifisintpgfmathresult
pgfmathprintnumberpgfmathresult$pi$

pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


begindocument


begintikzpicture[>=latex]
datavisualization [
school book axes, %scientific axes=clean,
all axes=,
x axis=
label=$omega t$,
ticks=
step=(pi/2),
tick typesetter/.code=mytypesetter##1,
,
y axis=
label=$v$,
ticks=none,
,
style sheet=strong colors,
style sheet=vary dashing,
visualize as smooth line/.list=voltage,
voltage=label in legend=text=$v$,
]
data [set=voltage, format=function]
var x : interval [0:2*pi] samples 100;
func y = 2*sin(value x r);
;
beginscope[on background layer]
fill[red] plot[variable=x,domain=0:pi] (x,2*sin(x r));
path[pattern=horizontal lines,pattern color=red]
plot[variable=x,domain=pi:2*pi] (x,2*sin(x r));
endscope
endtikzpicture
enddocument


enter image description here



This lets you keep what you had and add the fills where needed.




Let me also comment that Symbol 1's nice answer can be used here. I stress that I have close to zero knowledge on the data visualization business, so I may make things unnecessarily complicated. The strategy is from Symbol 1's nice answer, except that I allow the style to be redefined via tikzsetchange style=draw,pattern=horizontal lines,pattern color=red (yes, I know that is a stupid name for a pgf key, yet I feel that this is not the only thing that I am doing stupid here. This works, but is far more complicated than JouleV's nice code. There is a good chance that (at least) part of the complexity is due to my ignorance with regards to data visualization.



documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarydatavisualization
usetikzlibrarypatterns
usetikzlibrarydatavisualization.formats.functions
defmytypesetter#1
pgfmathparse#1/pi
pgfkeys/pgf/number format/precision=2
pgfmathroundtozerofillpgfmathresult
pgfmathifisintpgfmathresult
pgfmathprintnumberpgfmathresult$pi$

pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


makeatletter%from https://tex.stackexchange.com/a/228265/121799
tikzdatavisualizationset
visualize as generic/.style=
new object=
when=after survey,
store=/tikz/data visualization/visualizers/#1,
class=plot handler visualizer,
arg1=#1,
arg2=tikz@dv@plot@handler,tikz@dv@plot@mark@maker
,
new visualizer=#1%
every path/.style=generic style,
style=every mark/.append style=color=visualizer color,
mark size=2pt,
semithick,
color=visualizer color,
mark=none,
/tikz/data visualization/every visualize as line/.try,
visualizer in legend=tikz@dv@legend@entry@as@example,
#1=straight line
,
visualize as generic/.default=generic,

tikzsetchange style/.code=tikzsetgeneric style/.style=#1,
change style=draw,fill=red
makeatother
begindocument


begintikzpicture[>=latex]
datavisualization [
school book axes, %scientific axes=clean,
all axes=,
x axis=include value=6.3,
label=$omega t$,
ticks=
step=(pi/2),
tick typesetter/.code=mytypesetter##1,
,
y axis=include value=-2,
label=$v$,
ticks=none,
,
style sheet=strong colors,
style sheet=vary dashing,
visualize as generic,
%visualize as smooth line/.list=voltage,
% voltage=label in legend=text=$v$,
]
data [format=function] % set=voltage,
var x : interval [0:pi] samples 100;
func y = 2*sin(value x r);
;
tikzsetchange style=draw,pattern=horizontal lines,pattern color=red
datavisualization [
school book axes, %scientific axes=clean,
all axes=,
x axis=include value=6.3,
label=$omega t$,
ticks=
step=(pi/2),
tick typesetter/.code=mytypesetter##1,
,
y axis=include value=2,
label=$v$,
ticks=none,
,
style sheet=strong colors,
style sheet=vary dashing,
visualize as generic,
%visualize as smooth line/.list=voltage,
% voltage=label in legend=text=$v$,
]
data [format=function]
var x : interval [pi:2*pi] samples 100;
func y = 2*sin(value x r);
;
endtikzpicture
enddocument


enter image description here






share|improve this answer

























  • It's working...

    – Özgür
    Mar 24 at 2:14











  • @Özgür I added a simple possibility that allows you to keep your 50+ plots and add fills where needed.

    – marmot
    Mar 24 at 3:07











  • I have a small suggestion: the red color seems to overfill the ωt axis a bit.

    – JouleV
    Mar 24 at 16:02











  • @JouleV Yes, that's true, thanks! One has to use the same number of samples to get a perfect match.

    – marmot
    Mar 24 at 17:28


















8














A pure TikZ solution for fun, which is much shorter. I have no idea why you have to use datavisualization for this.



documentclass[tikz]standalone
usetikzlibrarypatterns
begindocument
begintikzpicture[>=latex,y=2cm]
draw[smooth,fill=red] plot[samples=100,domain=0:pi] (x,sin(deg(x)));
draw[smooth,pattern=horizontal lines,pattern color=red] plot[samples=100,domain=pi:2*pi] (x,sin(deg(x)));
draw[->] (0,-1.1)--(0,1.1) node[above] $v$;
draw[->] (-.2,0)--(2*pi+0.5,0) node[right] $omega t$;
draw (pi/2,-.05) node[below] $frac12pi$--(pi/2,.05);
draw (pi,-.05) node[below] $1pi$--(pi,.05);
draw (3*pi/2,-.05) node[below] $frac32pi$--(3*pi/2,.05);
draw (2*pi,-.05) node[below] $2pi$--(2*pi,.05);
draw (8.5,0) node tikzdraw[x=1pt,y=1pt] (0,0) to[out=30,in=-150] (20,0); $v$;
endtikzpicture
enddocument


enter image description here






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481119%2fhow-do-i-color-the-graph-in-datavisualization%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    Nothing prevents you from adding the fills on the background.



    documentclass[tikz,border=10pt]standalone
    usetikzlibrarydatavisualization
    usetikzlibrarydatavisualization.formats.functions
    usetikzlibrarypatterns,backgrounds
    defmytypesetter#1
    pgfmathparse#1/pi
    pgfkeys/pgf/number format/precision=2
    pgfmathroundtozerofillpgfmathresult
    pgfmathifisintpgfmathresult
    pgfmathprintnumberpgfmathresult$pi$

    pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


    begindocument


    begintikzpicture[>=latex]
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as smooth line/.list=voltage,
    voltage=label in legend=text=$v$,
    ]
    data [set=voltage, format=function]
    var x : interval [0:2*pi] samples 100;
    func y = 2*sin(value x r);
    ;
    beginscope[on background layer]
    fill[red] plot[variable=x,domain=0:pi] (x,2*sin(x r));
    path[pattern=horizontal lines,pattern color=red]
    plot[variable=x,domain=pi:2*pi] (x,2*sin(x r));
    endscope
    endtikzpicture
    enddocument


    enter image description here



    This lets you keep what you had and add the fills where needed.




    Let me also comment that Symbol 1's nice answer can be used here. I stress that I have close to zero knowledge on the data visualization business, so I may make things unnecessarily complicated. The strategy is from Symbol 1's nice answer, except that I allow the style to be redefined via tikzsetchange style=draw,pattern=horizontal lines,pattern color=red (yes, I know that is a stupid name for a pgf key, yet I feel that this is not the only thing that I am doing stupid here. This works, but is far more complicated than JouleV's nice code. There is a good chance that (at least) part of the complexity is due to my ignorance with regards to data visualization.



    documentclass[tikz,border=10pt]standalone
    usepackagetikz
    usetikzlibrarydatavisualization
    usetikzlibrarypatterns
    usetikzlibrarydatavisualization.formats.functions
    defmytypesetter#1
    pgfmathparse#1/pi
    pgfkeys/pgf/number format/precision=2
    pgfmathroundtozerofillpgfmathresult
    pgfmathifisintpgfmathresult
    pgfmathprintnumberpgfmathresult$pi$

    pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


    makeatletter%from https://tex.stackexchange.com/a/228265/121799
    tikzdatavisualizationset
    visualize as generic/.style=
    new object=
    when=after survey,
    store=/tikz/data visualization/visualizers/#1,
    class=plot handler visualizer,
    arg1=#1,
    arg2=tikz@dv@plot@handler,tikz@dv@plot@mark@maker
    ,
    new visualizer=#1%
    every path/.style=generic style,
    style=every mark/.append style=color=visualizer color,
    mark size=2pt,
    semithick,
    color=visualizer color,
    mark=none,
    /tikz/data visualization/every visualize as line/.try,
    visualizer in legend=tikz@dv@legend@entry@as@example,
    #1=straight line
    ,
    visualize as generic/.default=generic,

    tikzsetchange style/.code=tikzsetgeneric style/.style=#1,
    change style=draw,fill=red
    makeatother
    begindocument


    begintikzpicture[>=latex]
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=include value=6.3,
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=include value=-2,
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as generic,
    %visualize as smooth line/.list=voltage,
    % voltage=label in legend=text=$v$,
    ]
    data [format=function] % set=voltage,
    var x : interval [0:pi] samples 100;
    func y = 2*sin(value x r);
    ;
    tikzsetchange style=draw,pattern=horizontal lines,pattern color=red
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=include value=6.3,
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=include value=2,
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as generic,
    %visualize as smooth line/.list=voltage,
    % voltage=label in legend=text=$v$,
    ]
    data [format=function]
    var x : interval [pi:2*pi] samples 100;
    func y = 2*sin(value x r);
    ;
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer

























    • It's working...

      – Özgür
      Mar 24 at 2:14











    • @Özgür I added a simple possibility that allows you to keep your 50+ plots and add fills where needed.

      – marmot
      Mar 24 at 3:07











    • I have a small suggestion: the red color seems to overfill the ωt axis a bit.

      – JouleV
      Mar 24 at 16:02











    • @JouleV Yes, that's true, thanks! One has to use the same number of samples to get a perfect match.

      – marmot
      Mar 24 at 17:28















    4














    Nothing prevents you from adding the fills on the background.



    documentclass[tikz,border=10pt]standalone
    usetikzlibrarydatavisualization
    usetikzlibrarydatavisualization.formats.functions
    usetikzlibrarypatterns,backgrounds
    defmytypesetter#1
    pgfmathparse#1/pi
    pgfkeys/pgf/number format/precision=2
    pgfmathroundtozerofillpgfmathresult
    pgfmathifisintpgfmathresult
    pgfmathprintnumberpgfmathresult$pi$

    pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


    begindocument


    begintikzpicture[>=latex]
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as smooth line/.list=voltage,
    voltage=label in legend=text=$v$,
    ]
    data [set=voltage, format=function]
    var x : interval [0:2*pi] samples 100;
    func y = 2*sin(value x r);
    ;
    beginscope[on background layer]
    fill[red] plot[variable=x,domain=0:pi] (x,2*sin(x r));
    path[pattern=horizontal lines,pattern color=red]
    plot[variable=x,domain=pi:2*pi] (x,2*sin(x r));
    endscope
    endtikzpicture
    enddocument


    enter image description here



    This lets you keep what you had and add the fills where needed.




    Let me also comment that Symbol 1's nice answer can be used here. I stress that I have close to zero knowledge on the data visualization business, so I may make things unnecessarily complicated. The strategy is from Symbol 1's nice answer, except that I allow the style to be redefined via tikzsetchange style=draw,pattern=horizontal lines,pattern color=red (yes, I know that is a stupid name for a pgf key, yet I feel that this is not the only thing that I am doing stupid here. This works, but is far more complicated than JouleV's nice code. There is a good chance that (at least) part of the complexity is due to my ignorance with regards to data visualization.



    documentclass[tikz,border=10pt]standalone
    usepackagetikz
    usetikzlibrarydatavisualization
    usetikzlibrarypatterns
    usetikzlibrarydatavisualization.formats.functions
    defmytypesetter#1
    pgfmathparse#1/pi
    pgfkeys/pgf/number format/precision=2
    pgfmathroundtozerofillpgfmathresult
    pgfmathifisintpgfmathresult
    pgfmathprintnumberpgfmathresult$pi$

    pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


    makeatletter%from https://tex.stackexchange.com/a/228265/121799
    tikzdatavisualizationset
    visualize as generic/.style=
    new object=
    when=after survey,
    store=/tikz/data visualization/visualizers/#1,
    class=plot handler visualizer,
    arg1=#1,
    arg2=tikz@dv@plot@handler,tikz@dv@plot@mark@maker
    ,
    new visualizer=#1%
    every path/.style=generic style,
    style=every mark/.append style=color=visualizer color,
    mark size=2pt,
    semithick,
    color=visualizer color,
    mark=none,
    /tikz/data visualization/every visualize as line/.try,
    visualizer in legend=tikz@dv@legend@entry@as@example,
    #1=straight line
    ,
    visualize as generic/.default=generic,

    tikzsetchange style/.code=tikzsetgeneric style/.style=#1,
    change style=draw,fill=red
    makeatother
    begindocument


    begintikzpicture[>=latex]
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=include value=6.3,
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=include value=-2,
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as generic,
    %visualize as smooth line/.list=voltage,
    % voltage=label in legend=text=$v$,
    ]
    data [format=function] % set=voltage,
    var x : interval [0:pi] samples 100;
    func y = 2*sin(value x r);
    ;
    tikzsetchange style=draw,pattern=horizontal lines,pattern color=red
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=include value=6.3,
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=include value=2,
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as generic,
    %visualize as smooth line/.list=voltage,
    % voltage=label in legend=text=$v$,
    ]
    data [format=function]
    var x : interval [pi:2*pi] samples 100;
    func y = 2*sin(value x r);
    ;
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer

























    • It's working...

      – Özgür
      Mar 24 at 2:14











    • @Özgür I added a simple possibility that allows you to keep your 50+ plots and add fills where needed.

      – marmot
      Mar 24 at 3:07











    • I have a small suggestion: the red color seems to overfill the ωt axis a bit.

      – JouleV
      Mar 24 at 16:02











    • @JouleV Yes, that's true, thanks! One has to use the same number of samples to get a perfect match.

      – marmot
      Mar 24 at 17:28













    4












    4








    4







    Nothing prevents you from adding the fills on the background.



    documentclass[tikz,border=10pt]standalone
    usetikzlibrarydatavisualization
    usetikzlibrarydatavisualization.formats.functions
    usetikzlibrarypatterns,backgrounds
    defmytypesetter#1
    pgfmathparse#1/pi
    pgfkeys/pgf/number format/precision=2
    pgfmathroundtozerofillpgfmathresult
    pgfmathifisintpgfmathresult
    pgfmathprintnumberpgfmathresult$pi$

    pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


    begindocument


    begintikzpicture[>=latex]
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as smooth line/.list=voltage,
    voltage=label in legend=text=$v$,
    ]
    data [set=voltage, format=function]
    var x : interval [0:2*pi] samples 100;
    func y = 2*sin(value x r);
    ;
    beginscope[on background layer]
    fill[red] plot[variable=x,domain=0:pi] (x,2*sin(x r));
    path[pattern=horizontal lines,pattern color=red]
    plot[variable=x,domain=pi:2*pi] (x,2*sin(x r));
    endscope
    endtikzpicture
    enddocument


    enter image description here



    This lets you keep what you had and add the fills where needed.




    Let me also comment that Symbol 1's nice answer can be used here. I stress that I have close to zero knowledge on the data visualization business, so I may make things unnecessarily complicated. The strategy is from Symbol 1's nice answer, except that I allow the style to be redefined via tikzsetchange style=draw,pattern=horizontal lines,pattern color=red (yes, I know that is a stupid name for a pgf key, yet I feel that this is not the only thing that I am doing stupid here. This works, but is far more complicated than JouleV's nice code. There is a good chance that (at least) part of the complexity is due to my ignorance with regards to data visualization.



    documentclass[tikz,border=10pt]standalone
    usepackagetikz
    usetikzlibrarydatavisualization
    usetikzlibrarypatterns
    usetikzlibrarydatavisualization.formats.functions
    defmytypesetter#1
    pgfmathparse#1/pi
    pgfkeys/pgf/number format/precision=2
    pgfmathroundtozerofillpgfmathresult
    pgfmathifisintpgfmathresult
    pgfmathprintnumberpgfmathresult$pi$

    pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


    makeatletter%from https://tex.stackexchange.com/a/228265/121799
    tikzdatavisualizationset
    visualize as generic/.style=
    new object=
    when=after survey,
    store=/tikz/data visualization/visualizers/#1,
    class=plot handler visualizer,
    arg1=#1,
    arg2=tikz@dv@plot@handler,tikz@dv@plot@mark@maker
    ,
    new visualizer=#1%
    every path/.style=generic style,
    style=every mark/.append style=color=visualizer color,
    mark size=2pt,
    semithick,
    color=visualizer color,
    mark=none,
    /tikz/data visualization/every visualize as line/.try,
    visualizer in legend=tikz@dv@legend@entry@as@example,
    #1=straight line
    ,
    visualize as generic/.default=generic,

    tikzsetchange style/.code=tikzsetgeneric style/.style=#1,
    change style=draw,fill=red
    makeatother
    begindocument


    begintikzpicture[>=latex]
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=include value=6.3,
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=include value=-2,
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as generic,
    %visualize as smooth line/.list=voltage,
    % voltage=label in legend=text=$v$,
    ]
    data [format=function] % set=voltage,
    var x : interval [0:pi] samples 100;
    func y = 2*sin(value x r);
    ;
    tikzsetchange style=draw,pattern=horizontal lines,pattern color=red
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=include value=6.3,
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=include value=2,
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as generic,
    %visualize as smooth line/.list=voltage,
    % voltage=label in legend=text=$v$,
    ]
    data [format=function]
    var x : interval [pi:2*pi] samples 100;
    func y = 2*sin(value x r);
    ;
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer















    Nothing prevents you from adding the fills on the background.



    documentclass[tikz,border=10pt]standalone
    usetikzlibrarydatavisualization
    usetikzlibrarydatavisualization.formats.functions
    usetikzlibrarypatterns,backgrounds
    defmytypesetter#1
    pgfmathparse#1/pi
    pgfkeys/pgf/number format/precision=2
    pgfmathroundtozerofillpgfmathresult
    pgfmathifisintpgfmathresult
    pgfmathprintnumberpgfmathresult$pi$

    pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


    begindocument


    begintikzpicture[>=latex]
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as smooth line/.list=voltage,
    voltage=label in legend=text=$v$,
    ]
    data [set=voltage, format=function]
    var x : interval [0:2*pi] samples 100;
    func y = 2*sin(value x r);
    ;
    beginscope[on background layer]
    fill[red] plot[variable=x,domain=0:pi] (x,2*sin(x r));
    path[pattern=horizontal lines,pattern color=red]
    plot[variable=x,domain=pi:2*pi] (x,2*sin(x r));
    endscope
    endtikzpicture
    enddocument


    enter image description here



    This lets you keep what you had and add the fills where needed.




    Let me also comment that Symbol 1's nice answer can be used here. I stress that I have close to zero knowledge on the data visualization business, so I may make things unnecessarily complicated. The strategy is from Symbol 1's nice answer, except that I allow the style to be redefined via tikzsetchange style=draw,pattern=horizontal lines,pattern color=red (yes, I know that is a stupid name for a pgf key, yet I feel that this is not the only thing that I am doing stupid here. This works, but is far more complicated than JouleV's nice code. There is a good chance that (at least) part of the complexity is due to my ignorance with regards to data visualization.



    documentclass[tikz,border=10pt]standalone
    usepackagetikz
    usetikzlibrarydatavisualization
    usetikzlibrarypatterns
    usetikzlibrarydatavisualization.formats.functions
    defmytypesetter#1
    pgfmathparse#1/pi
    pgfkeys/pgf/number format/precision=2
    pgfmathroundtozerofillpgfmathresult
    pgfmathifisintpgfmathresult
    pgfmathprintnumberpgfmathresult$pi$

    pgfmathprintnumber[/pgf/number format/frac, frac denom=2, frac whole=false]pgfmathresult$pi$


    makeatletter%from https://tex.stackexchange.com/a/228265/121799
    tikzdatavisualizationset
    visualize as generic/.style=
    new object=
    when=after survey,
    store=/tikz/data visualization/visualizers/#1,
    class=plot handler visualizer,
    arg1=#1,
    arg2=tikz@dv@plot@handler,tikz@dv@plot@mark@maker
    ,
    new visualizer=#1%
    every path/.style=generic style,
    style=every mark/.append style=color=visualizer color,
    mark size=2pt,
    semithick,
    color=visualizer color,
    mark=none,
    /tikz/data visualization/every visualize as line/.try,
    visualizer in legend=tikz@dv@legend@entry@as@example,
    #1=straight line
    ,
    visualize as generic/.default=generic,

    tikzsetchange style/.code=tikzsetgeneric style/.style=#1,
    change style=draw,fill=red
    makeatother
    begindocument


    begintikzpicture[>=latex]
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=include value=6.3,
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=include value=-2,
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as generic,
    %visualize as smooth line/.list=voltage,
    % voltage=label in legend=text=$v$,
    ]
    data [format=function] % set=voltage,
    var x : interval [0:pi] samples 100;
    func y = 2*sin(value x r);
    ;
    tikzsetchange style=draw,pattern=horizontal lines,pattern color=red
    datavisualization [
    school book axes, %scientific axes=clean,
    all axes=,
    x axis=include value=6.3,
    label=$omega t$,
    ticks=
    step=(pi/2),
    tick typesetter/.code=mytypesetter##1,
    ,
    y axis=include value=2,
    label=$v$,
    ticks=none,
    ,
    style sheet=strong colors,
    style sheet=vary dashing,
    visualize as generic,
    %visualize as smooth line/.list=voltage,
    % voltage=label in legend=text=$v$,
    ]
    data [format=function]
    var x : interval [pi:2*pi] samples 100;
    func y = 2*sin(value x r);
    ;
    endtikzpicture
    enddocument


    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 24 at 3:06

























    answered Mar 24 at 1:57









    marmotmarmot

    113k5145275




    113k5145275












    • It's working...

      – Özgür
      Mar 24 at 2:14











    • @Özgür I added a simple possibility that allows you to keep your 50+ plots and add fills where needed.

      – marmot
      Mar 24 at 3:07











    • I have a small suggestion: the red color seems to overfill the ωt axis a bit.

      – JouleV
      Mar 24 at 16:02











    • @JouleV Yes, that's true, thanks! One has to use the same number of samples to get a perfect match.

      – marmot
      Mar 24 at 17:28

















    • It's working...

      – Özgür
      Mar 24 at 2:14











    • @Özgür I added a simple possibility that allows you to keep your 50+ plots and add fills where needed.

      – marmot
      Mar 24 at 3:07











    • I have a small suggestion: the red color seems to overfill the ωt axis a bit.

      – JouleV
      Mar 24 at 16:02











    • @JouleV Yes, that's true, thanks! One has to use the same number of samples to get a perfect match.

      – marmot
      Mar 24 at 17:28
















    It's working...

    – Özgür
    Mar 24 at 2:14





    It's working...

    – Özgür
    Mar 24 at 2:14













    @Özgür I added a simple possibility that allows you to keep your 50+ plots and add fills where needed.

    – marmot
    Mar 24 at 3:07





    @Özgür I added a simple possibility that allows you to keep your 50+ plots and add fills where needed.

    – marmot
    Mar 24 at 3:07













    I have a small suggestion: the red color seems to overfill the ωt axis a bit.

    – JouleV
    Mar 24 at 16:02





    I have a small suggestion: the red color seems to overfill the ωt axis a bit.

    – JouleV
    Mar 24 at 16:02













    @JouleV Yes, that's true, thanks! One has to use the same number of samples to get a perfect match.

    – marmot
    Mar 24 at 17:28





    @JouleV Yes, that's true, thanks! One has to use the same number of samples to get a perfect match.

    – marmot
    Mar 24 at 17:28











    8














    A pure TikZ solution for fun, which is much shorter. I have no idea why you have to use datavisualization for this.



    documentclass[tikz]standalone
    usetikzlibrarypatterns
    begindocument
    begintikzpicture[>=latex,y=2cm]
    draw[smooth,fill=red] plot[samples=100,domain=0:pi] (x,sin(deg(x)));
    draw[smooth,pattern=horizontal lines,pattern color=red] plot[samples=100,domain=pi:2*pi] (x,sin(deg(x)));
    draw[->] (0,-1.1)--(0,1.1) node[above] $v$;
    draw[->] (-.2,0)--(2*pi+0.5,0) node[right] $omega t$;
    draw (pi/2,-.05) node[below] $frac12pi$--(pi/2,.05);
    draw (pi,-.05) node[below] $1pi$--(pi,.05);
    draw (3*pi/2,-.05) node[below] $frac32pi$--(3*pi/2,.05);
    draw (2*pi,-.05) node[below] $2pi$--(2*pi,.05);
    draw (8.5,0) node tikzdraw[x=1pt,y=1pt] (0,0) to[out=30,in=-150] (20,0); $v$;
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer



























      8














      A pure TikZ solution for fun, which is much shorter. I have no idea why you have to use datavisualization for this.



      documentclass[tikz]standalone
      usetikzlibrarypatterns
      begindocument
      begintikzpicture[>=latex,y=2cm]
      draw[smooth,fill=red] plot[samples=100,domain=0:pi] (x,sin(deg(x)));
      draw[smooth,pattern=horizontal lines,pattern color=red] plot[samples=100,domain=pi:2*pi] (x,sin(deg(x)));
      draw[->] (0,-1.1)--(0,1.1) node[above] $v$;
      draw[->] (-.2,0)--(2*pi+0.5,0) node[right] $omega t$;
      draw (pi/2,-.05) node[below] $frac12pi$--(pi/2,.05);
      draw (pi,-.05) node[below] $1pi$--(pi,.05);
      draw (3*pi/2,-.05) node[below] $frac32pi$--(3*pi/2,.05);
      draw (2*pi,-.05) node[below] $2pi$--(2*pi,.05);
      draw (8.5,0) node tikzdraw[x=1pt,y=1pt] (0,0) to[out=30,in=-150] (20,0); $v$;
      endtikzpicture
      enddocument


      enter image description here






      share|improve this answer

























        8












        8








        8







        A pure TikZ solution for fun, which is much shorter. I have no idea why you have to use datavisualization for this.



        documentclass[tikz]standalone
        usetikzlibrarypatterns
        begindocument
        begintikzpicture[>=latex,y=2cm]
        draw[smooth,fill=red] plot[samples=100,domain=0:pi] (x,sin(deg(x)));
        draw[smooth,pattern=horizontal lines,pattern color=red] plot[samples=100,domain=pi:2*pi] (x,sin(deg(x)));
        draw[->] (0,-1.1)--(0,1.1) node[above] $v$;
        draw[->] (-.2,0)--(2*pi+0.5,0) node[right] $omega t$;
        draw (pi/2,-.05) node[below] $frac12pi$--(pi/2,.05);
        draw (pi,-.05) node[below] $1pi$--(pi,.05);
        draw (3*pi/2,-.05) node[below] $frac32pi$--(3*pi/2,.05);
        draw (2*pi,-.05) node[below] $2pi$--(2*pi,.05);
        draw (8.5,0) node tikzdraw[x=1pt,y=1pt] (0,0) to[out=30,in=-150] (20,0); $v$;
        endtikzpicture
        enddocument


        enter image description here






        share|improve this answer













        A pure TikZ solution for fun, which is much shorter. I have no idea why you have to use datavisualization for this.



        documentclass[tikz]standalone
        usetikzlibrarypatterns
        begindocument
        begintikzpicture[>=latex,y=2cm]
        draw[smooth,fill=red] plot[samples=100,domain=0:pi] (x,sin(deg(x)));
        draw[smooth,pattern=horizontal lines,pattern color=red] plot[samples=100,domain=pi:2*pi] (x,sin(deg(x)));
        draw[->] (0,-1.1)--(0,1.1) node[above] $v$;
        draw[->] (-.2,0)--(2*pi+0.5,0) node[right] $omega t$;
        draw (pi/2,-.05) node[below] $frac12pi$--(pi/2,.05);
        draw (pi,-.05) node[below] $1pi$--(pi,.05);
        draw (3*pi/2,-.05) node[below] $frac32pi$--(3*pi/2,.05);
        draw (2*pi,-.05) node[below] $2pi$--(2*pi,.05);
        draw (8.5,0) node tikzdraw[x=1pt,y=1pt] (0,0) to[out=30,in=-150] (20,0); $v$;
        endtikzpicture
        enddocument


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 23 at 20:34









        JouleVJouleV

        9,39322256




        9,39322256



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481119%2fhow-do-i-color-the-graph-in-datavisualization%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

            Luettelo Yhdysvaltain laivaston lentotukialuksista Lähteet | Navigointivalikko

            Gary (muusikko) Sisällysluettelo Historia | Rockin' High | Lähteet | Aiheesta muualla | NavigointivalikkoInfobox OKTuomas "Gary" Keskinen Ancaran kitaristiksiProjekti Rockin' High