question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing scale type on existing figure

See original GitHub issue

I’m building a multipurpose dashboard that should be able to graph a wide variety of data with different settings. One of the requirements is being able to graph against milliseconds while another is to graph against datetimes. I currently have code similar to the following:

x_sc = DateScale()
y_sc = LinearScale()

ax_x = Axis(label='time', scale=x_sc, grid_lines='solid', tick_format='%m/%d/%y', tick_rotate=90)
ax_y = Axis(label='y_val', scale=y_sc, orientation='vertical', tick_format='0.2f')
pz = PanZoom(scales={'x': [x_sc], 'y': [y_sc]})
data = Lines(x=x_data, y=y_data, scales={'x': x_sc, 'y': y_sc})

zoom_interacts = widgets.ToggleButtons(options=OrderedDict([
                                        (' ', None),
                                        ('xy ', pz)]),
                                        icons = ["stop", "arrows"]
                                        )



fig = Figure(axes=[ax_x, ax_y], marks=[data])
link((zoom_interacts, 'value'), (fig, 'interaction'))
widgets.HBox([fig, zoom_interacts])

swap = widgets.Select(
    options=['dates', 'ms'],
    description='Swap',
    disabled=False
)
def swapAxes(b):
    global x_data
    global ax_x
    global data
    global fig
    if(b == 'dates'):
        ax_x.scale = DateScale()
        x_data = date_data
    else:
        ax_x.scale = LinearScale()
        x_data = ms_data
 
    
interactive(swapAxes, b=swap)

where y_data, date_data, and ms_data are all numpy arrays. When the figure first renders it works as long as I’m using ms_data with a linear scale or date_data with a date scale. But when I try to change the scale using the select the values on the x_axis simply disappear. Is there a way to change this scale back and forth between a date scale and a linear scale?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
shorstmancommented, Oct 3, 2018

That worked great! Thank you so much for the help!

0reactions
DougRzzcommented, Oct 2, 2018

datescale

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change axis values of an already existing figure - MathWorks
I have a figure that has axis already and numbers in them. I wish to change the axis values display values so that...
Read more >
Changing plot scale by a factor in matplotlib - Stack Overflow
As you have noticed, xscale and yscale does not support a simple linear re-scaling (unfortunately). As an alternative to Hooked's answer, ...
Read more >
Change the scale of the horizontal (category) axis in a chart
To reverse the order of categories, expand Axis Options, and then select the Categories in reverse order check box. · To change the...
Read more >
How to Add Remove and Change Scale Factors - YouTube
AutoCAD Productivity Training Webinar Available Now: https://gumroad.com/l/oPLLa ** Sign up for Updates and Free Downloads: ...
Read more >
How to scale objects without changing dimensions - YouTube
To scale an object, simply type in the command line SCALE and select the objects you want to scale. You can select dimensions...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found