Package: directplot
python-directplotEducational library to directly plot single data points.DescriptionEducational library to directly plot single data points.ATTENTION: This library is slow and not suited for production use!It has been developed for educational purpose, especially to visualize
numerical algorithms e.g. for simulation or plotting measurement data.It wraps matplotlib and pyplot commands in even simpler commands:importmathimportdirectplotasdpdp.init()foriinrange(51):x=i*2*math.pi/50y=math.sin(x)dp.add(0,x,y)dp.waitforclose()The following functions are provided:init()Initializes and opens a Direct Plot windowadd()Adds a single point to a plot lineshowMarker()Shows or hides marker points on a plot line or on all plot lineslabel()Changes the label of a plot line used in the legendtitle()Changes the title of a sub-plotxylabel()Changes the axis lables of a sub-plotrefresh()Refreshes the contents of the plot windowclose()Closes the Direct Plot windowclear()Deletes the contents of the plot windowwaitforclose()Updates the title on the plot window and blocks execution until user closes the plot window.APIFunctions are listed alphabetical order. Unless otherwise noted, the return type isNone.add()Adds a single point to a plot line.If the number of points per plot line exceedsmaxPoints(seeinit()), the oldest point is removed automatically, resulting in a scroll behavior of the plots.add(id,x,y,refresh=True)Parameter:id(int) – The id of the target plot linex(float) – x valuey(float) – y valuerefresh(bool) – Determines if the plot is refreshed immediately resulting in slower plotting speed. Optional with defaultTrueExampledp.add(0,0.1,2.7)dp.add(1,1.1,7.3,False)dp.add(1,1.2,7.2)clear()Deletes the contents of the plot window.Keeps the number of sub-plots, the number of lines per sub-plot and the titles of the sub-plots. Everything else is reset/deleted.clear()Exampledp.clear()close()Closes the Single Point Plot window.close()Exampledp.close()init()Initializes and opens a Single Point Plot window.init(titles=['Single-Point-Plot'],linesPerSubplot=4,showMarker=True,maxPoints=10000,grid:bool=True)Parametertitles(list(str)) – A list or tuple containing 1 to 3 strings, resulting in 1 to 3 sub-plots on the plot window. Optional with a default title for a single sub-plot.linesPerSubplot(int) – Number of lines (data series) per sub-plot. Optional with default4showMarker(bool) – Determines if data points are emphasized with a little dot. Optional with defaultTruemaxPoints(int) - Maximum number of data points per line (data series). Optional with default 10000If the number of points per plot line exceedsmaxPoints, the oldest point is removed automatically, resulting in a scroll behavior of the plots.grid(bool): Display plot grid. Optional with default TrueExampledp.init()ordp.init(["Results"])ordp.init(["Height","Speed","Forces"],linesPerSubplot=2,showMarker=False)ordp.init(["Temperature °C","Pressure mbar","Humidity %"],linesPerSubplot=1,maxPoints=100)label()Changes the label of a plot line used in the legend.label(id,label)Parameterid(int) – The id of the target plot linelabel(str) – The new label textExampledp.label(0,"mass in kg")refresh()Refreshes the contents of the plot window.Mostly used in conjunction withadd()andrefresh=False.refresh()Exampledp.add(0,0.1,7.3,False)dp.add(0,0.2,6.9,False)dp.add(0,0.3,2.1,False)dp.refresh()showMarker()Shows or hides marker points on a plot line or on all plot lines.showMarker(show=True,id=None)Parametershow(bool) – Show or hide markes. Optional with defaultTrueid(int) – The id of the target plot line. Optional with defaultNoneresulting in a change of markers on all plot lines.Exampledp.showMarker()ordp.showMarker(False,1)title()Changes the title of a sub-plottitle(id,title)Parameterid(int) – The id of the target plot line used to determine the corresponding sub-plottitle(str) – The new title textExampledp.title(0,"Simulated Values")waitforclose()Updates the title on the plot window and blocks execution until user closes the plot window.waitforclose(msg=None)Parametermsg(str) – A string to be shown on the window title and on stdout. Optional with defaultNoneresulting in a standard titleExampledp.waitforclose()ordp.waitforclose("PLEASE CLOSE THE DIRECT PLOT WINDOW")xylabel()Changes the axis lables of a sub-plot.xylabel(id,xlabel,ylabel)Parameterid(int) – The id of the target plot line used to determine the corresponding sub-plotxlabel(str) – New label for the x axisylabel(str) – New label for the y axisExampledp.xylabel(0,"time in s","force in N")DevelopmentBuild pypi packageTools needed to build and publish to PyPi under Windows:python -m pip install --upgrade build
python -m pip install --upgrade twineTools needed to build and publish to PyPi Linux/MacOS:python3 -m pip install --upgrade build
python3 -m pip install --upgrade twineBuild package:python -m buildUpload package to pypi:Before uploading, delete outdated build artifacts in thedistfolder, such that only the latest build files are uploaded.twine upload dist/*