Git Product home page Git Product logo

Comments (9)

tammoippen avatar tammoippen commented on May 28, 2024

Hi @andresriancho ,

Thank you! I am happy that it is useful for you 😊 . Regarding the issue: it looks like you are not using the latest version. I ran into the same displaying issues and made some changes in v3.2 that should keep labels in their 8-9 characters. Please try updating and see if that fixes the issue?

BTW: It looks like you are plotting timestamps (vs ... something else ;) ). In v3.2 it should be possible to directly give the datetime objects as X values.

from plotille.

andresriancho avatar andresriancho commented on May 28, 2024

Awesome! Upgrading fixed 50% of my problem: now I can read the values 👍

What about only displaying the integer part of the number in the X axis?

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

Right now, there are no plans to only show integer parts, or have an option for this... anyway, with the last update, you can supply formatters to a figure, that will render all labels (also the Y-axis), e.g.:

from plotille import *
import random

def _num_formatter(val, chars, delta, left=False):
    align = '<' if left else ''
    return '{:{}{}d}'.format(int(val), align, chars)

fig = Figure()
fig.width = 30
fig.height = 15
fig.register_label_formatter(float, _num_formatter)
fig.register_label_formatter(int, _num_formatter)
fig.plot(list(range(100)), [random.randint(0, 20) for _i in range(100)])
print(fig.show())

screen shot 2018-02-13 at 09 23 40

from plotille.

andresriancho avatar andresriancho commented on May 28, 2024

Lovely, you rock!

screenshot from 2018-02-13 11-33-44

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

😊 Thx.

from plotille.

andresriancho avatar andresriancho commented on May 28, 2024

Just in case you were wondering, your tool is being used to graph the results of parsing https://github.com/andresriancho/w3af scan log files:

https://github.com/andresriancho/w3af/blob/80b3cc71ea501e21ead9077d5b03f23a5247a3e6/w3af/core/controllers/profiling/scan_log_analysis.py

That tool generates nice output which allows me to better understand what w3af is doing internally, and how to improve it.

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

Wow! 👍 You got another ⭐️! I will definitely look into that project.😄

Since you actually plot datetimes (as timestamp deltas), have you tried to insert them directly? Replacing the line 179 by:

error_rate_timestamps = [datetime.datetime.fromtimestamp(ts) for ts in error_rate_timestamps]

and line 198 with:

fig.set_x_limits(min_=datetime.datetime.fromtimestamp(first_timestamp), max_=datetime.datetime.fromtimestamp(last_timestamp))

Depending on the delta (aka spent_epoch) this will plot the actual time (or day and time).

from plotille.

andresriancho avatar andresriancho commented on May 28, 2024

Applied the changes you recommended to see how the output looked and got an exception:

  File "/home/caveman/tools/virtualenvs/w3af/local/lib/python2.7/site-packages/plotille/_figure.py", line 258, in show
    self.background, self.color_mode)
  File "/home/caveman/tools/virtualenvs/w3af/local/lib/python2.7/site-packages/plotille/_canvas.py", line 68, in __init__
    assert isinstance(xmin, (int, float))
AssertionError

The modified code:

def show_extended_urllib_error_rate(scan):
    error_rate = []
    error_rate_timestamps = []

    for line in scan:
        match = EXTENDED_URLLIB_ERRORS_RE.search(line)
        if match:
            error_rate.append(int(match.group(1)))
            error_rate_timestamps.append(get_line_epoch(line))

    first_timestamp = get_first_timestamp(scan)
    last_timestamp = get_last_timestamp(scan)
    spent_epoch = last_timestamp - first_timestamp
    #error_rate_timestamps = [ts - first_timestamp for ts in error_rate_timestamps]
    error_rate_timestamps = [datetime.datetime.fromtimestamp(ts) for ts in error_rate_timestamps]

    if not error_rate:
        print('No error rate information found')
        return

    print('Extended URL library error rate')
    print('    Error rate exceeded 10%%: %s' % (max(error_rate) > 10,))
    print('    Error rate exceeded 20%%: %s' % (max(error_rate) > 10,))
    print('')

    fig = plotille.Figure()
    fig.width = 90
    fig.height = 20
    #fig.register_label_formatter(float, _num_formatter)
    #fig.register_label_formatter(int, _num_formatter)
    fig.y_label = 'Error rate'
    fig.x_label = 'Time'
    fig.color_mode = 'byte'
    fig.set_x_limits(min_=datetime.datetime.fromtimestamp(first_timestamp),
                     max_=datetime.datetime.fromtimestamp(last_timestamp))
    fig.set_y_limits(min_=0, max_=max(error_rate) * 1.1)

    fig.plot(error_rate_timestamps,
             error_rate,
             label='Error rate')

    print(fig.show())
    print('')
    print('')

I actually like the way the X axis looks like without the proposed change. I can see seconds since the beginning of the scan, which is easier to understand than a date / hour.

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

Thank you for the catch! The project is still young and I am happy for every feedback 😁.

from plotille.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.