<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 TRAPpy
Step1:  Interactive Line Plotting of Data Frames
Interactive Line Plots Supports the same API as the LinePlot but provide an interactive plot that can be zoomed by clicking and dragging on the desired area. Double clicking resets the zoom.
We can create an interactive plot easily from a dataframe by passing the data frame and the columns we want to plot as parameters
Step2:  Plotting independent series
It is also possible to plot traces with different index values (i.e. x-axis values)
Step3:  This does not affect filtering or pivoting in any way
Step4:  Interactive Line Plotting of Traces
We can also create them from trace objects
Step5:  You can also change the drawstyle to "steps-post" for step plots. These are suited if the data is discrete 
and linear interploation is not required between two data points
Step6:  Synchronized zoom in multiple plots
ILinePlots can zoom all at the same time.  You can do so using the group and sync_zoom parameter.  All ILinePlots using the same group name zoom at the same time.
Step7:  EventPlot
TRAPpy's  Interactive Plotter features an Interactive Event TimeLine Plot. It accepts an input data of the type
<pre>
<code>
                   { "A" 
Step8:  Lane names can also be specified as strings (or hashable objects that have an str representation) as follows
Step9:  TracePlot
A specification of the EventPlot creates a kernelshark like plot if the sched_switch event is enabled in the traces
<ASSISTANT_TASK:>
Python Code:
import sys,os
sys.path.append("..")
import numpy.random
import pandas as pd
import shutil
import tempfile
import trappy
trace_thermal = "./trace.txt"
trace_sched = "../tests/raw_trace.dat"
TEMP_BASE = "/tmp"
def setup_thermal():
    tDir = tempfile.mkdtemp(dir="/tmp", prefix="trappy_doc", suffix = ".tempDir")
    shutil.copyfile(trace_thermal, os.path.join(tDir, "trace.txt"))
    return tDir
def setup_sched():
    tDir = tempfile.mkdtemp(dir="/tmp", prefix="trappy_doc", suffix = ".tempDir")
    shutil.copyfile(trace_sched, os.path.join(tDir, "trace.dat"))
    return tDir
temp_thermal_location = setup_thermal()
trace1 = trappy.FTrace(temp_thermal_location)
trace2 = trappy.FTrace(temp_thermal_location)
trace2.thermal.data_frame["temp"] = trace1.thermal.data_frame["temp"] * 2
trace2.cpu_out_power.data_frame["power"] = trace1.cpu_out_power.data_frame["power"] * 2
Explanation: TRAPpy: Interactive Plotting
Re Run the cells to generate the graphs
End of explanation
columns = ["tick", "tock"]
df = pd.DataFrame(numpy.random.randn(1000, 2), columns=columns).cumsum()
trappy.ILinePlot(df, column=columns).view()
Explanation: Interactive Line Plotting of Data Frames
Interactive Line Plots Supports the same API as the LinePlot but provide an interactive plot that can be zoomed by clicking and dragging on the desired area. Double clicking resets the zoom.
We can create an interactive plot easily from a dataframe by passing the data frame and the columns we want to plot as parameters:
End of explanation
columns = ["tick", "tock", "bang"]
df_len = 1000
df1 = pd.DataFrame(numpy.random.randn(df_len, 3), columns=columns, index=range(df_len)).cumsum()
df2 = pd.DataFrame(numpy.random.randn(df_len, 3), columns=columns, index=(numpy.arange(0.5, df_len, 1))).cumsum()
trappy.ILinePlot([df1, df2], column="tick").view()
Explanation: Plotting independent series
It is also possible to plot traces with different index values (i.e. x-axis values)
End of explanation
df1["bang"] = df1["bang"].apply(lambda x: numpy.random.randint(0, 4))
df2["bang"] = df2["bang"].apply(lambda x: numpy.random.randint(0, 4))
trappy.ILinePlot([df1, df2], column="tick", filters = {'bang' : [2]}, title="tick column values for which bang is 2").view()
trappy.ILinePlot([df1, df2], column="tick", pivot="bang", title="tick column pivoted on bang column").view()
Explanation: This does not affect filtering or pivoting in any way
End of explanation
    map_label = {
            "00000000,00000006" : "A57",
            "00000000,00000039" : "A53",
    }
    l = trappy.ILinePlot(
            trace1,                                          # TRAPpy FTrace Object
            trappy.cpu_power.CpuInPower,                     # TRAPpy Event (maps to a unique word in the Trace)
            column=[                                         # Column(s)
                "dynamic_power",
                "load1"],
            
            filters={                                        # Filter the data  
                "cdev_state": [
                    1,
                    0]},
            pivot="cpus",                                    # One plot for each pivot will be created
            map_label=map_label,                             # Optionally, provide an alternative label for pivots
            per_line=1)                                      # Number of graphs per line
    l.view()
Explanation: Interactive Line Plotting of Traces
We can also create them from trace objects
End of explanation
        l = trappy.ILinePlot(
            trace1,                                          # TRAPpy FTrace Object
            trappy.cpu_power.CpuInPower,                     # TRAPpy Event (maps to a unique word in the Trace)
            column=[                                         # Column(s)
                "dynamic_power",
                "load1"],
            
            filters={                                        # Filter the data  
                "cdev_state": [
                    1,
                    0]},
            pivot="cpus",                                    # One plot for each pivot will be created
        
            per_line=1,                                      # Number of graphs per line
            drawstyle="steps-post")                                     
        l.view()
Explanation: You can also change the drawstyle to "steps-post" for step plots. These are suited if the data is discrete 
and linear interploation is not required between two data points
End of explanation
trappy.ILinePlot(
    trace1,
    signals=["cpu_in_power:dynamic_power", "cpu_in_power:load1"],
    pivot="cpus",
    group="synchronized",
    sync_zoom=True
).view()
Explanation: Synchronized zoom in multiple plots
ILinePlots can zoom all at the same time.  You can do so using the group and sync_zoom parameter.  All ILinePlots using the same group name zoom at the same time.
End of explanation
A = [
    
        [0, 3, 0],
        [4, 5, 2],
]
B = [
        [0, 2, 1],
        [2, 3, 3],
        [3, 4, 0],
]
C =  [
        [0, 2, 3],
        [2, 3, 2],
        [3, 4, 1],
]
EVENTS = {}
EVENTS["A"] = A
EVENTS["B"] = B
EVENTS["C"] = C
trappy.EventPlot(EVENTS,
                 keys=EVENTS.keys,                     # Name of the Process Element
                 lane_prefix="LANE: ",                 # Name of Each TimeLine
                 num_lanes=4,                          # Number of Timelines
                 domain=[0,5]                          # Time Domain
                ).view()
Explanation: EventPlot
TRAPpy's  Interactive Plotter features an Interactive Event TimeLine Plot. It accepts an input data of the type
<pre>
<code>
                   { "A" : [
                                    [event_start, event_end, lane],
                                    .
                                    .
                                    [event_start, event_end, lane],
                                 ],
                     .
                     .
                     .
                     "B" : [
                                    [event_start, event_end, lane],
                                    .
                                    .
                                    [event_start, event_end, lane],
                    .
                    .
                    .
                   }
</code>
</pre>
Hovering on the rectangles gives the name of the process element and scrolling on the Plot Area and the window in the summary controls the zoom. One can also click and drag for panning a zoomed graph.
For Example:
End of explanation
A = [
    
        [0, 3, "zero"],
        [4, 5, "two"],
]
B = [
        [0, 2, 1],
        [2, 3, "three"],
        [3, 4, "zero"],
]
C =  [
        [0, 2, "three"],
        [2, 3, "two"],
        [3, 4, 1],
]
EVENTS = {}
EVENTS["A"] = A
EVENTS["B"] = B
EVENTS["C"] = C
trappy.EventPlot(EVENTS,
                 keys=EVENTS.keys,                     # Name of the Process Element
                 lanes=["zero", 1, "two", "three"],
                 domain=[0,5]                          # Time Domain
                ).view()
Explanation: Lane names can also be specified as strings (or hashable objects that have an str representation) as follows
End of explanation
f = setup_sched()
trappy.plotter.plot_trace(f)
Explanation: TracePlot
A specification of the EventPlot creates a kernelshark like plot if the sched_switch event is enabled in the traces
End of explanation
<END_TASK>