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

ECDF Stat #832

Merged
merged 17 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move scaling of the Y axis inside the step geometry.
  • Loading branch information
ASmirnov-HORIS committed Jul 31, 2023
commit 410b7d6db2a4e9a82b9c74ad8f6ce266f167ea92
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.jetbrains.letsPlot.core.plot.base.geom

import org.jetbrains.letsPlot.commons.geometry.DoubleVector
import org.jetbrains.letsPlot.commons.interval.DoubleSpan
import org.jetbrains.letsPlot.core.plot.base.*
import org.jetbrains.letsPlot.core.plot.base.geom.util.GeomHelper
import org.jetbrains.letsPlot.core.plot.base.geom.util.GeomUtil
Expand All @@ -14,7 +15,7 @@ import org.jetbrains.letsPlot.core.plot.base.geom.util.TargetCollectorHelper
import org.jetbrains.letsPlot.core.plot.base.render.SvgRoot
import org.jetbrains.letsPlot.datamodel.svg.dom.SvgLineElement

class StepGeom : LineGeom() {
class StepGeom : LineGeom(), WithHeight {
private var myDirection = DEF_DIRECTION
var padded = DEF_PADDED

Expand Down Expand Up @@ -100,6 +101,19 @@ class StepGeom : LineGeom() {
return pads
}

override fun heightSpan(
p: DataPointAesthetics,
coordAes: Aes<Double>,
resolution: Double,
isDiscrete: Boolean
): DoubleSpan? {
return when {
padded -> DoubleSpan(0.0, 1.0)
p.x()?.isFinite() == true && p.y()?.isFinite() == true -> DoubleSpan(p.y()!!, p.y()!!)
else -> DoubleSpan(-0.5, 0.5)
}
}

enum class Direction {
HV, VH;

Expand Down
8 changes: 1 addition & 7 deletions python-package/lets_plot/plot/stat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2023. JetBrains s.r.o.
# Use of this source code is governed by the MIT license that can be found in the LICENSE file.
from .geom import _geom
from .scale_convenience import xlim, ylim

#
# Stats - functions, drawing attention to the statistical transformation rather than the visual appearance.
Expand Down Expand Up @@ -463,10 +462,6 @@ def stat_ecdf(mapping=None, *, data=None, geom=None,
"""
ecdf_geom = geom if geom is not None else 'step'
ecdf_pad = pad if pad is not None else True
if orientation == 'y':
limits_spec = xlim(0, 1)
else:
limits_spec = ylim(0, 1)
return _geom(ecdf_geom,
mapping=mapping,
data=data,
Expand All @@ -479,5 +474,4 @@ def stat_ecdf(mapping=None, *, data=None, geom=None,
n=n,
pad=ecdf_pad,
color_by=color_by,
**other_args) + \
limits_spec
**other_args)