Qalculate / libqalculate

Qalculate! library and CLI
https://qalculate.github.io/
GNU General Public License v2.0
1.86k stars 148 forks source link

Ploting graphs in terminal #214

Open RustemB opened 4 years ago

RustemB commented 4 years ago
hanna-kn commented 4 years ago

Yes, and yes. It does however require that Gnuplot is installed (and found in path).

You can either use to the plot() function, or File->Plot Functions/Data (in the GUI).

plot function documentation:

Plot Functions and Vectors

plot(Expression or vector[, Minimum x value][, Maximum x value][, Number of samples / Step size][, X variable][, Use step size][, Persistent])

Plots one or more expressions or vectors. Use a vector for the first argument to plot multiple series. Only the first argument is used for vector series. It is also possible to plot a matrix where each row is a pair of x and y values.

Example: plot([x^2, 2x, [0,1,4,8,16]], 0, 4).

Arguments.

  • Expression or vector: a free value
  • Minimum x value: a real number (optional, default: 0)
  • Maximum x value: a real number (optional, default: 10)
  • Number of samples / Step size: a free value (optional, default: 1001)
  • X variable: an unknown variable/symbol (optional, default: x)
  • Use step size: a boolean (0 or 1) (optional, default: 0)
  • Persistent: a boolean (0 or 1) (optional, default: 0)

Requirement. "Minimum x value" < "Maximum x value"

RustemB commented 4 years ago

But it's opens me GUI gnuplot, and i want "ascii-ish" inside of terminal, 'cuz it looks weird for me image

hanna-kn commented 4 years ago

i want "ascii-ish" inside of terminal

That is currently not possible (and will likely never be—an ascii plot would not be very useful because of the low resolution).

RustemB commented 4 years ago

sadly :(

i-ky commented 4 years ago

Actually, gnuplot itself supports ASCII output using set terminal dumb ...:

The dumb terminal driver plots into a text block using ascii characters. It has an optional size specification and a trailing linefeed flag.

Maybe it is not that difficult to implement? And maybe it's not that useless if gnuplot has this feature?

hanna-kn commented 4 years ago

Maybe it is not that difficult to implement?

echo "set term dumb" >> ~/.gnuplot should be enough.

And maybe it's not that useless if gnuplot has this feature?

To me, this output appears close to useless: Skärmbild från 2020-08-03 13-34-37

danr commented 4 years ago

There are projects that use Braille symbols to make plots in the terminal, eg https://github.com/sunetos/TextPlots.jl https://github.com/asciimoo/drawille :woman_shrugging:

yump commented 2 years ago

On that note, the upcoming gnuplot 5.5 (not yet packaged in my distro) has added the block terminal, which uses that trick. There's also the sixelgd terminal, which has been around longer and is somewhat more capable but less compatible (doesn't work in tmux, for example).

With set term sixelgd truecolor size 480,280 font "sans,8" in ~/.gnuplot it looks like

Screenshot_20220719_020324