You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to create a bar chart of sin function by sampling a value on every natural number (sin 1, sin 2, etc.) but, I also want to overlay continuous sin function over that bar chart. I kind of understand why this isn't directly possible with bar chart, but maybe there is some trick that could help?
Currently I'm using "points" to represent how tall the bar would be for my disc array, but I can't replace plot $ points mempty disc with plot $ fmap plotBars $ bars [""] $ addIndexes $ fmap ( (:[]) . snd ) disc otherwise I get an error for obvious reasons.
importGraphics.Rendering.Chart.EasyimportGraphics.Rendering.Chart.Backend.Cairo--sinG::IO()
sinG = toFile def "sinus-continuous.png"$do-- hi res "continuous" sin datalet cont = [ ( x, sin x ) | x <- [ 0,0.1..50 ] :: [ Double ] ]
-- lo res discrete sin datalet disc = [ ( x, sin x ) | x <- [ 0,1..50] :: [ Double ] ]
layout_title .="Sinus Function"
plot $ line mempty [ cont ]
plot $ points mempty disc
This is how my discrete graph would look:
sinG::IO()
sinG = toFile def "sinus-discrete.png"$do-- lo res discrete sin datalet disc = [ ( x, sin x ) | x <- [ 0,1..50] :: [ Double ] ]
layout_title .="Sinus Function"
plot $fmap plotBars $ bars [""] $ addIndexes $fmap ( (:[]) .snd ) disc
And here is the final result that I want to achieve (rendered in photoshop 😄):
The text was updated successfully, but these errors were encountered:
I want to create a bar chart of
sin
function by sampling a value on every natural number (sin 1
,sin 2
, etc.) but, I also want to overlay continuoussin
function over that bar chart. I kind of understand why this isn't directly possible with bar chart, but maybe there is some trick that could help?Currently I'm using "points" to represent how tall the bar would be for my
disc
array, but I can't replaceplot $ points mempty disc
withplot $ fmap plotBars $ bars [""] $ addIndexes $ fmap ( (:[]) . snd ) disc
otherwise I get an error for obvious reasons.This is how my discrete graph would look:
And here is the final result that I want to achieve (rendered in photoshop 😄):
The text was updated successfully, but these errors were encountered: