Giter Club home page Giter Club logo

Comments (6)

newville avatar newville commented on June 15, 2024

@Spandyie Zooming works OK for me. Without example code and more details of what you expect to happen, I cannot tell what is not working as you expect.

from wxmplot.

Spandyie avatar Spandyie commented on June 15, 2024

@newville Below is the Python class which uses wxmpanel, I created a derived panel class using wxmpanel.PlotPanel. Everytime I call new instance of ConvexHullPlot() the zoom-in feature zooms into the graph created by previous instance of wxmplot

class ConvexHullPlot(wxmplot.PlotPanel):
    # TODO: The Convex Hull plot should be visible along with the point, test the outliers
    """" Plots the convex hull plot """
    def __init__(self, parent_panel, bm_torsion=None,bm_torsion_array=None, table_id="1"):
        super().__init__(parent=parent_panel, size=(600, 600))
        #########################################
        tor_bend_object = OpenThreshold(table_id)        # this class creates threshold object
        torsion_array = tor_bend_object.get_torsion()
        bm_array = tor_bend_object.get_bending_moment()
        data_list = [Point(int(x), int(y)) for x, y in zip(torsion_array,bm_array)]
        ###########################################
        # create a stack of convex hull object,
        stack_object = ConvexHull(data_list)        # creates a convexhull class
        # creating a deep-copy of the stack to plot the graph
        stacks = copy.deepcopy(stack_object.hull)
        # check if the stack object is empty or not
        assert not stack_object.hull.isEmpty
        t = []
        s = []
        # check the size of the stack
        length_stack = stacks.size
        assert length_stack >= 3
        for i in range(length_stack):
            temp_point = stacks.pop()
            t.append(temp_point.x)
            s.append(temp_point.y)
        #########################################
        t = np.array(t)
        s = np.array(s)
        #############################################
        # plot outliers in red and non-outliers in green
        if bm_torsion is not None:
            outlier_detector = DetectOutlier(bm_torsion, stack_object.hull)
            if outlier_detector.is_outlier():
                # plot the outlier
                duration = 1000  # millisecond
                freq = 1000 # Hz
                x, y = np.array([bm_torsion.get_x()]), np.array([bm_torsion.get_y()])
                self.scatterplot(x, y, marker='*', s=100, color='red', xlabel="Bending Moment", ylabel="Torsion Moment")
                self.oplot(t, s, alpha=0.6, color="red")
                winsound.Beep(freq, duration)  # play the sound
                self.status_message = "Outlier detected"
            else:
                # plot the inlier
                x, y = np.array([bm_torsion.get_x()]), np.array([bm_torsion.get_y()])
                self.scatterplot(x, y, marker='*', s=100, color='green', xlabel="Bending Moment", ylabel="Torsion Moment")
                self.oplot(t, s,  alpha=0.6, color="red")
                self.status_message = "Data is within threshold"

        elif bm_torsion is None and bm_torsion_array is not None:
            bending_moment_all = list()
            torsion_moment_all = list()
            points_on_the_hull = copy.deepcopy(stack_object.hull)
            for point in bm_torsion_array:
                # create an outlier detector object
                # refill the convex hull because it gets emptied after outlier detection
                # points_on_the_hull = copy.deepcopy(stack_object.hull)
                # outlier_detector = DetectOutlier(point, points_on_the_hull)
                bending_moment_all.append(point.get_x())
                torsion_moment_all.append(point.get_y())
                # check if the point in the array is outlier
                #if outlier_detector.is_outlier():
                #    pass
                #else:
                #    pass
            bending_moment_all = np.array(bending_moment_all)
            torsion_moment_all = np.array(torsion_moment_all)
            self.scatterplot(bending_moment_all, torsion_moment_all, marker="*")
            self.oplot(t, s, color="red")
            self.set_xlabel("Bending Moment")
            self.set_ylabel("Torsion Moment")
        else:
            self.plot(t, s, color="blue")

from wxmplot.

newville avatar newville commented on June 15, 2024

@Spandyie That code does not run for me. If you are creating instances of this class many times, wouldn't you need to say how you were doing that? Are you reusing a panel or something? I have no idea.

If you suspect there is a problem with wxmplot, please provide a minimal example that demonstrates whatever problem you are seeing.

from wxmplot.

Spandyie avatar Spandyie commented on June 15, 2024

@newville I apologise for leaving out the details. This code has many other dependencies class such as DetectOutlier() , ConvexHull() which is part of a larger software.

The Class ConvexHullPlot()'s parent is another subpanel. Yes I am reusing panel. Please see the attachment for the Snapshot of GUI.
Debug.pptx

from wxmplot.

newville avatar newville commented on June 15, 2024

@Spandyie Well, I have no idea what your code does or is supposed to do. That makes it essentially impossible to guess what you are seeing that you do not expect.

Am I supposed to see something in the pptx file? What, exactly? No, really, if you want me to know, you need to tell me explicitly. I cannot tell if you are trying to illustrate a bug or ask how to do something. Please post a minimal, complete (working) code that illustrates the problem.

from wxmplot.

Spandyie avatar Spandyie commented on June 15, 2024

Solved the Problem apparently I had to destroy the all the children panel in the parent panel to solve the issue
following lines of code above super().init() solve it:
for child in parent_panel.GetChildren(): child.Destroy()

from wxmplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.