metasoarous / oz

Data visualizations in Clojure and ClojureScript using Vega and Vega-lite
Eclipse Public License 1.0
829 stars 74 forks source link

How to control size of graphics file. #200

Closed jimka2001 closed 5 months ago

jimka2001 commented 5 months ago

This is a very similar issue as another I filed a few seconds ago.

I have a clojure function, series-format-plot-data, defined here https://github.com/jimka2001/clojurein-student/blob/ce1e21511a04d17f851a294f39fcf7b457f4427e/clojurein-source-code/src/lecture/vega_plot.clj#L8 which creates a plot using oz. I can't figure out how to set the size of the image file.

When I call the function, sample-plot-2, defined here https://github.com/jimka2001/clojurein-student/blob/ce1e21511a04d17f851a294f39fcf7b457f4427e/clojurein-source-code/src/lecture/baby_name_plot.clj#L98 I get a graphs of the following size. I'd like to have larger images. Baby Names 36789401800512485415

The basic data structure I'm passing in a file to oz/export! is the following. I'm hoping it is possible to declare the size in cm or pixels somewhere in this format.

    {:data {:values polished-data}
     :title {:text chart-title}
     :description chart-title
     :axes [{:orient "bottom"
             ;; TODO this is NOT setting the label
             :title x-label}
            {:orient "left"
             ;; TODO this is NOT setting the label
             :title y-label}]
     :encoding {:x {:field "x" ;; x-label
                    :type "quantitative"}
                :y {:field "y" ;; y-label
                    :type "quantitative"}
                :color {:field "series"
                        :type "nominal"}}
     :mark "line"}
jimka2001 commented 5 months ago

I found this source: https://vega.github.io/vega-lite/docs/size.html

I've added :width and :height to the data and it seems to work.

    {:data {:values polished-data}
     :width 600
     :height 600
     :title {:text chart-title}
     :description chart-title
     :axes [{:orient "bottom"
             :title x-label}
            {:orient "left"
             :title y-label}]
     :encoding {:x {:field x-label
                    :type "quantitative"}
                :y {:field y-label
                    :type "quantitative"}
                :color {:field "series"
                        :type "nominal"}}
     :mark "line"}