1. pip install pyperclip 2. git pull
3. copy example data 4. Ctrl+B return: *no script selected* *Is there anything wrong with my operation?* 在2021年11月12日星期五 UTC+8 上午11:02:04<[email protected]> 写道: > If you have a node that reads or computes some X-Y data, you can add axis > labels and a title to your clipboard plot by protecting the *[labels]* > section with and "@" directive. This causes the following text to be > ignored when the script is executed by CNTL-B of with VR3, but it does not > hide the section from the plot clipboard command. Here is an example. > Let's read annual global surface temperature from a file, then plot it. > The file will contain rows like this: > > 1900 0.395 > 1901 0.438 > # etc. > > The code and the *[labels] *section could look like this: > > import pyperclip > datafile = r'c:\data\sst.txt' > with open(datafile) as file: > data = file.read() > pyperclip.copy(data) > > @ > [labels] > title = Global Surface Temperature Vs Year > xaxis = Year > yaxis = "Global Average Surface Temperature, Deg C. > > When you run this node, say with CTRL-B, the file will be read and its > contents copied to the clipboard. When you invoke the plotting command, > the data in the clipboard will be plotted, and the graph's title and axis > labels will be taken from the *[labels]* section of the node. The "@" > directive prevents the section from being interpreted as code. > On Monday, November 8, 2021 at 8:10:42 PM UTC-5 [email protected] wrote: > >> I have adapted the code for Viewrendered3's new ability to plot data in >> nodes, and with minor changes it functions as a stand-alone command to take >> data from the clipboard and plot it. So if you get one- or two-column data >> into the clipboard you can take a quick look at it. >> >> Here is an example of X-Y data: >> >> 1 1 >> 2 .5 >> 3 -6 >> # comment >> ; comment >> >> 4 -16 >> 5 -2 >> 6 5 >> 7 10 >> >> Non-numeric lines are ignored except for special configuration sections, >> so you can copy a large range of data sources and plot them instantly. You >> could also do some computation in a node that you run with CTRL-B, and add >> a few lines to format it and copy it to the clipboard. I have found that >> ability to be very useful while I've developed code. The script is very >> flexible and robust (so far as I know, anyway). >> >> You do need to install *pyperclip* (for getting the clipboard), and >> *matplotlib* to do the actual plotting - you probably have it installed >> already. You could change the script to use Leo's own clipboard code or >> some other clipboard package; I just happen to like pyperclip and think >> it's easy to use. >> >> As of this evening, the script is in *scripts.leo* in the *devel* >> branch, under a new node with the headline *Plots and Graphs*. More >> information and usage details are in the docstring of the script, and the >> new *Help for plot-2d* menu item in VR3 is very applicable since the >> code is largely the same. >> > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/f7e703e2-af33-4d63-9b4e-f54d7cb7ab4dn%40googlegroups.com.
