How to stop GNUPLOT 5.4.5 after defining DATA command and how to clear command window - gnuplot

I have big troubles when manual inputing data acc. to: https://stackoverflow.com/questions/69532716/simple-line-from-two-points-continuing-through-points
When i start to typing data, I mean when i define points and want to correct sth - I cannot do that.
GNU plot starts to using very strange chars. And i cannot clear any data I already defined.
I dont even know how to stop gnuplot and continue my job.
Can anyone help me how to correct my data or maybe how to re-run gnuplot with simple command?
Is it also possible to clear command window in GNUPLOT 5.4.5 (windows)?
I tried to use CTRL - C, CTRL - D commands to return to default typing and it does not work. For clearing command window i tried to use clear or CLC or system 'cls' command and cannot achieve required effect :/

Related

Gnuplot won't open window when called via CPP file

I'm trying to get some practice with C and C++ by playing with gnuplot, but whilst following an example on plotting a simple 2 column data file, I encountered an issue.
When I call gnuplot in my script, it refuses to open any window, and doesn't appear to do any work at all. I don't think this is an issue of window persistence, as I don't even see it open for a split second. I've tried fiddling with setting a persistent terminal and pausing after plotting to no avail. My CPU's activity meter never spikes as it does when I run my other example functions, leading me to believe it never opens in the first place.
However, the strangest part to me is that I managed to plot the data file with gnuplot just how I'd hoped to, but the only way I was able to get it to work was running gnuplot as a terminal command via system().
Below is my function I'm testing with. As the comments note, that system call seems to work perfectly, but I'd prefer to use gnuplot "regularly," not via system calls.
void ex2() {
Gnuplot gp("\"C:\\Program Files\\gnuplot\\bin\\gnuplot.exe\"");
// system("gnuplot -p -e \"plot '2col.dat'\""); #works for some reason?????
gp << "plot '2col.dat'\n";
std::cin.get();
}
I'd appreciate any help you can offer! I just want to be able to plot the file with the "gp <<" notation. I apologize if this is similar to another thread here, but every similar one I've found was solved by adding "pause mouse close" at the end or changing the terminal persist setting, which have not worked for me.

How is the fancy command line implemented in Linux?

When installing things in Linux I often see stdout change after printing eg. there might be a counter showing installation progress that starts at 1% and goes up to 100%. How is this done? When I write C programs and I print something using printf, I can't change it afterwards - if I type 1%, it stays that way. How is it done? Is there a different function I have to use?
\r brings you back to the beginning of the line without issuing the \n to go to the next line. Use this to overwrite text on the screen to build progress bars, etc.
See:
How to add a progress bar to a shell script?

Easy way to colour ALL user input in terminal?

I know that there is lots of info for colouring the output of certain commands, but I want to have a specific colour for everything I write into the Mac terminal.
It would allow me to have a special colour for everything I input - not the output, just the code I personally input - making it easy to scan the code to where the last command was. I want to find a way to do it without having to write a colour alias for every single command - A way that by default will implement a unique colour for everything I write in the terminal.
Thanks for your help.
I have now sorted this...
Open your ~/.bash_profile in whatever editor you prefer.
Add the following code:
export PS1="\e[0;32m[\u#\h \W]\$ \e[m"
and save.
You will now see that your command prompt is coloured green, and it's super easy to find yourself in the terminal :)
Hope that's helpful for anyone trying to fix the same problem!
P.S> These instructions cover more than just the colour in the terminal... They also control what it shown in your command prompt. I'm afraid that it will need someone way more advanced at coding than me to decipher which bit refers to what... Sorry!

Node command line interface change

I'm making a command interface for a node server, but I have reached a point that I want it to look better.
I want to have the console so you enter a command at the bottom of the terminal screen, you hit enter, and it adds the reply to the actual command line.
If you have ever run a minecraft bukkit server from the command line, you should know what I'm talking about.
Here's a picture of what I'm talking about if you still don't understand. Imagine this was in terminal, and ignore the scroll bars: http://cl.ly/1K0h1V0r0H3f3U3t3L22
Is there anyway to set the console to look like this without having to make your own program for it or having the screen reprint all the other info to fake that look?
I have not done this, but I believe something similar is possible with very little effort by using Node.js REPL. You can override the eval parameter to provide your own command processing.
It would not have the exact look you are wanting, but it will be an interactive prompt that you can utilize (more similar to a Windows command shell or a Linux shell).
If you want the exact look from your screenshot, I don't believe that there is any Node.js module that will help you. There are some that allow you to use colors in the console, and some basic highlighting (e.g. bold), but nothing that gives you complete control over the console screen.

Keep Matlab plot window visible, when executing script from terminal

Following some great advices, as this: suppress start message of Matlab I now use this line to execute Matlab script from within my preferred editor, without launching whole Matlab machinery:
matlab -nosplash -nojvm -logfile /tmp/matlab-log -wait < "$(FilePath)" \
> /dev/null 2 && sed '1,9d' /tmp/matlab-log
-nodisplay switch is omitted as I want to be able to see plot output.
However, when using above line to evoke script that produces plot, plot window appears and then immediately disappears.
How to keep plot window visible, considering above execution line?
I know I could add waitforbuttonpress; in each plot script, but looking for something more automatic w/o complicating execution line too much
Try using the command uiwait in your script.
f = figure();
uiwait(f);
Presumably, your script contains an exit or quit statement, which is what causes MATLAB to close. You'd need to intercept that and wait for a keypress before actually quitting.
MATLAB runs the finish script before it closes, so you could use that. But it would need to be on the path.
Forgive me for asking, but is there a good reason you don't want to use the MATLAB editor?

Resources