Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quiet infer by default #178

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions src/ggplotnim/collect_and_fill.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import datamancer
import ginger except Scale

const StartHue {.intdefine.} = 15
const ggPlotDebugTypeInfer {.booldefine.} = false

proc addIdentityData(data: var Column, df: DataFrame, s: Scale) =
case s.col.kind
Expand Down Expand Up @@ -55,18 +56,20 @@ proc isDiscreteData(col: Column, s: Scale, drawSamples: static bool = true,
let elements = indices.mapIt(col[it, int]).toHashSet
if elements.card > (indices.len.float * discreteThreshold).round.int:
result = false
echo "INFO: The integer column `", $s.col, "` has been automatically ",
"determined to be continuous. To overwrite this behavior add a ",
"`+ scale_x/y_discrete()` call to the plotting chain. Choose `x`",
" or `y` depending on which axis this column refers to. Or apply a",
" `factor` to the column name in the `aes` call, i.e.",
" `aes(..., factor(\"" & $s.col & "\"), ...)`."
when ggPlotDebugTypeInfer:
echo "INFO: The integer column `", $s.col, "` has been automatically ",
"determined to be continuous. To overwrite this behavior add a ",
"`+ scale_x/y_discrete()` call to the plotting chain. Choose `x`",
" or `y` depending on which axis this column refers to. Or apply a",
" `factor` to the column name in the `aes` call, i.e.",
" `aes(..., factor(\"" & $s.col & "\"), ...)`."
else:
result = true
echo "INFO: The integer column `", $s.col, "` has been automatically ",
"determined to be discrete. To overwrite this behavior add a ",
"`+ scale_x/y_continuous()` call to the plotting chain. Choose `x`",
" or `y` depending on which axis this column refers to."
when ggPlotDebugTypeInfer:
echo "INFO: The integer column `", $s.col, "` has been automatically ",
"determined to be discrete. To overwrite this behavior add a ",
"`+ scale_x/y_continuous()` call to the plotting chain. Choose `x`",
" or `y` depending on which axis this column refers to."
of colFloat:
result = false
of colString:
Expand Down Expand Up @@ -100,15 +103,17 @@ proc isDiscreteData(col: Column, s: Scale, drawSamples: static bool = true,
discreteObjectCol = true
if not discreteObjectCol:
result = false
echo "INFO: The object column `", $s.col, "` has been automatically ",
"determined to be continuous. To overwrite this behavior use ",
"`scale_x/y_discrete` or apply `factor` to the column name in the `aes` ",
"call."
when ggPlotDebugTypeInfer:
echo "INFO: The object column `", $s.col, "` has been automatically ",
"determined to be continuous. To overwrite this behavior use ",
"`scale_x/y_discrete` or apply `factor` to the column name in the `aes` ",
"call."
else:
result = true
echo "INFO: The object column `", $s.col, "` has been automatically ",
"determined to be discrete. To overwrite this behavior use ",
"`scale_x/y_continuous`."
when ggPlotDebugTypeInfer:
echo "INFO: The object column `", $s.col, "` has been automatically ",
"determined to be discrete. To overwrite this behavior use ",
"`scale_x/y_continuous`."
of colNone:
raise newException(ValueError, "Input column " & $s.col & " is empty. Such a column " &
"cannot be plotted.")
Expand Down
18 changes: 9 additions & 9 deletions src/ggplotnim/ggplot_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,15 @@ type
bbSubset = "subset"

GeomKind* = enum
gkPoint = "geom_point"
gkBar = "geom_bar"
gkHistogram = "geom_histogram"
gkFreqPoly = "geom_freqpoly"
gkTile = "geom_tile"
gkLine = "geom_line"
gkErrorBar = "geom_errorbar"
gkText = "geom_text"
gkRaster = "geom_raster"
gkPoint = "point"
gkBar = "bar"
gkHistogram = "histogram"
gkFreqPoly = "freqpoly"
gkTile = "tile"
gkLine = "line"
gkErrorBar = "errorbar"
gkText = "text"
gkRaster = "raster"

HistogramDrawingStyle* = enum
hdBars = "bars" ## draws historams by drawing individual bars right next to
Expand Down
Loading