{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
module Text.Pandoc.Filter.Plot.Renderers.GGPlot2 (
ggplot2SupportedSaveFormats
, ggplot2Command
, ggplot2Capture
, ggplot2Available
) where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
ggplot2SupportedSaveFormats :: [SaveFormat]
ggplot2SupportedSaveFormats :: [SaveFormat]
ggplot2SupportedSaveFormats = [SaveFormat
PNG, SaveFormat
PDF, SaveFormat
SVG, SaveFormat
JPG, SaveFormat
EPS, SaveFormat
TIF]
ggplot2Command :: OutputSpec -> PlotM Text
ggplot2Command :: OutputSpec -> PlotM Text
ggplot2Command OutputSpec{..} = do
FilePath
exe <- Toolkit -> PlotM FilePath
executable Toolkit
GGPlot2
Text -> PlotM Text
forall (m :: * -> *) a. Monad m => a -> m a
return [st|#{exe} "#{oScriptPath}"|]
ggplot2Available :: PlotM Bool
ggplot2Available :: PlotM Bool
ggplot2Available = do
FilePath
exe <- Toolkit -> PlotM FilePath
executable Toolkit
GGPlot2
Text -> PlotM Bool
commandSuccess [st|#{exe} -e 'library("ggplot2")'|]
ggplot2Capture :: FigureSpec -> FilePath -> Script
ggplot2Capture :: FigureSpec -> FilePath -> Text
ggplot2Capture FigureSpec{..} fname :: FilePath
fname = [st|
library(ggplot2) # just in case
ggsave("#{fname}", plot = last_plot(), dpi = #{dpi})
|]