Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log scales ? #43

Open
katotheo opened this issue May 15, 2023 · 7 comments
Open

Log scales ? #43

katotheo opened this issue May 15, 2023 · 7 comments

Comments

@katotheo
Copy link

Is log scales possible? Any plans to add it? Thanks.

@kojix2
Copy link
Member

kojix2 commented May 15, 2023

Hello.
I see that you are proposing to add a log scale. Could you tell me what commands and command line options you are imagining?

@katotheo
Copy link
Author

Something per axis, e.g.
--ysetlogscale
defaulting to log of 10, or pass a number for different log...

I suppose one could process the data before feeding them to the plotter, but it would be a good convenience if plotter took care of that...

@kojix2
Copy link
Member

kojix2 commented May 16, 2023

You can use log scale for bar and count.

curl -sL https://git.io/ISLANDScsv \
| sort -nk2 -t, \
| tail -n15 \
| uplot bar -d, -t "Areas of the World's Major Landmasses" --xscale log
                   Areas of the World's Major Landmasses
                 ┌                                        ┐ 
         Britain ┤■■■■■■■■■■■■■■ 84.0                       
          Honshu ┤■■■■■■■■■■■■■■ 89.0                       
         Sumatra ┤■■■■■■■■■■■■■■■■■ 183.0                   
          Baffin ┤■■■■■■■■■■■■■■■■■ 184.0                   
      Madagascar ┤■■■■■■■■■■■■■■■■■ 227.0                   
          Borneo ┤■■■■■■■■■■■■■■■■■■ 280.0                  
      New Guinea ┤■■■■■■■■■■■■■■■■■■ 306.0                  
       Greenland ┤■■■■■■■■■■■■■■■■■■■■■ 840.0               
       Australia ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 2968.0          
          Europe ┤■■■■■■■■■■■■■■■■■■■■■■■■■■ 3745.0         
      Antarctica ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 5500.0        
   South America ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 6795.0       
   North America ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 9390.0      
          Africa ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 11506.0    
            Asia ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 16988.0   

when :barplot, :bar
sub_parser_add_symbol
sub_parser_add_fmt_yx
sub_parser_add_xscale
when :count, :c
sub_parser.on_head('-r', '--reverse', TrueClass, 'reverse the result of comparisons') do |v|
options.reverse = v
end
sub_parser_add_symbol
sub_parser_add_xscale

On the other hand, line, scatter, density, etc. cannot use log scale.

YouPlot is mostly a wrapper for the backend library UnicodePlot. So, it depends on unicode_plot whether log scaling is currently supported.

@kojix2
Copy link
Member

kojix2 commented May 16, 2023

Reading the README.md of the original Julia implementation of UnicodePlot, it appears that log scale is now supported.

image

And I hope Ruby's UnicodePlot will support it as well.

@katotheo
Copy link
Author

Sounds great, I'll use bar or count.

Shall we close this or keep it open as a reminder for the work for line, scatter, etc. ?

@kojix2
Copy link
Member

kojix2 commented May 16, 2023

Please leave this issue Open.

@llimllib
Copy link

llimllib commented Jun 29, 2023

It would be very useful for hist as well, ex the graph this presents is not super useful:

$ cat /usr/share/dict/words | grep -o ...$ | sort | uniq -c | uplot hist -n 20
                      ┌                                        ┐ 
   [    0.0,   500.0) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 4068   
   [  500.0,  1000.0) ┤ 45                                       
   [ 1000.0,  1500.0) ┤ 16                                       
   [ 1500.0,  2000.0) ┤ 4                                        
   [ 2000.0,  2500.0) ┤ 5                                        
   [ 2500.0,  3000.0) ┤ 5                                        
   [ 3000.0,  3500.0) ┤ 4                                        
   [ 3500.0,  4000.0) ┤ 1                                        
   [ 4000.0,  4500.0) ┤ 1                                        
   [ 4500.0,  5000.0) ┤ 1                                        
   [ 5000.0,  5500.0) ┤ 0                                        
   [ 5500.0,  6000.0) ┤ 1                                        
   [ 6000.0,  6500.0) ┤ 1                                        
   [ 6500.0,  7000.0) ┤ 1                                        
   [ 7000.0,  7500.0) ┤ 0                                        
   [ 7500.0,  8000.0) ┤ 0                                        
   [ 8000.0,  8500.0) ┤ 0                                        
   [ 8500.0,  9000.0) ┤ 0                                        
   [ 9000.0,  9500.0) ┤ 1                                        
                      └                                        ┘ 

(interpretation: most words don't end in a common ending, but a few endings are very very common)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants