Changing axes units

I have plotted a graph in mathematica, where the x axis is in seconds. I want to scale the axis so it displays years instead.

My plotting function is as follows:

Plot[sol1[t], {t, 0, 1 * 10^(16)},    PlotRange -> All    FrameLabel -> {"Time (s)", "Velocity (ms-1)"},    PlotStyle -> {Red, Thickness[0.01]}] 

Any help would be appreciated.

How to stop Mathematica 12.1 from chopping off the axes arrows?

Using the following code, I make a simple graph that is exported to pdf:

format = AxesStyle -> {{Thickness[.01], Arrowheads[{0.0, 0.05}]}, { Arrowheads[{0.0, 0.05}]} } graph = ListLinePlot[Table[{t, 2*t}, {t, 0, 100}], format, AspectRatio -> .2] Export[StringJoin[NotebookDirectory[], "\ext.pdf"], graph]; 

When I look at the graph, it cuts of the end of one of the arrows:

The y axis is ok – but the x axis is not. The end of the arrow has been clipped. It seems to be related to increasing the thickness of the axis.

For what its worth, the in-notebook display of the graph has complete arrows. It is only the exported version that is clipped.

I want both axes thick, and I want the whole arrow, and I want it in PDF. How to do this?

Please note that it didn’t have this problem in Mathematica 11.3; it is only after I upgraded that this problem has arisen. I’m using 12.1

Shaking axes when animating

I have the code below to animate a point. During the animation, the axes are shaking. I have added PlotRange, and PlotRangePadding -> None. Still shaking. If I export the animation to a gif, the Axes will stop shaking. Can anyone help?

  Graphics[    {     PointSize[0.02],     Point[{Cos[t], Cos[t]}]     },    PlotRange -> {{-2, 2}, {-2, 2}},    Axes -> True    ],   PlotRange -> {{-2, 2}, {-2, 2}},   PlotRangePadding -> None   ], {t, 0, 10, 0.1}] 

Axes Change in 3D Plot

I’d like to change the Axes. Please consider the following code:

Z[t_, \[Alpha]_] =t^3*\[Alpha];  Plot3D[Z[t, \[Alpha]], {t, 0, 2}, {\[Alpha], 0.5, 1}, AxesLabel -> {"t", "\[Alpha]", "Z"}] 

I want to chenge the Axes Z with \[Alpha], t with Z and \[Alpha] with t. Any suggestion?

How to control the labeling of axes in ContourPlot?

I’d like to change the labeling on the axes of a contour plot so that they are multiples of $$\pi$$. Any thoughts?

e.g.

ContourPlot[ Sin[x]* Cos[4 y], {x, 0, Pi}, {y, 0, Pi}]

How to control the labeling of axes in ContourPlot?

I’d like to change the labeling on the axes of a contour plot so that they are multiples of $$\pi$$. Any thoughts?

e.g.

ContourPlot[ Sin[x]* Cos[4 y], {x, 0, Pi}, {y, 0, Pi}]

why does changing axes size work differently inside and outside a function?

I’m working with existing code that creates a matplotlib figure with one axes, and adds a colorbar to it after-the-fact using make_axes_locatable and append_axes. It works, but I want to subsequently change the vertical height of the colorbar. I’ve figured out that this is only possible if I call the set_axes_locator(None) method on the colorbar axis (not 100% sure why) — if I don’t do that, any calls to cax.set_position() silently do nothing. Here’s the setup; question below:

import numpy as np import matplotlib.pyplot as plt from matplotlib.colorbar import ColorbarBase from mpl_toolkits.axes_grid1 import make_axes_locatable   def make_figure(n_levels, shrink=False):     data = np.random.randint(n_levels, size=(5, 7))     fig, ax = plt.subplots()     ax.imshow(data)     divider = make_axes_locatable(ax)     cax = divider.append_axes('right', size='5%', pad=0.1)     cmap = ax.images[0].get_cmap()     cmap = cmap._resample(n_levels)     _ = ColorbarBase(cax, cmap=cmap, norm=None, orientation='vertical')     if shrink:         shrink_colorbar(cax, n_levels)     return fig   def shrink_colorbar(cax, n_levels):     pos = cax.get_position().bounds     height = pos[-2] * n_levels     new_y = pos[1] + (pos[-1] - height) / 2     newpos = (pos[0], new_y, pos[2], height)     cax.set_axes_locator(None)     cax.set_position(newpos) 

If I do the colorbar resizing inside the function environment where the figure is created, I get the wrong result every time, whether I use regular Python REPL or iPython:

n_levels = 3 make_figure(n_levels, shrink=True) 

WRONG RESULT:

If I create the figure first, then shrink the colorbar after the fact, it works how I want it to as long as these lines are run separately (either in regular Python REPL with plt.ion(), or if each line is in a separate iPython cell):

fig = make_figure(n_levels) cax = fig.axes[-1] shrink_colorbar(cax, n_levels) 

CORRECT RESULT:

If those same lines are run as a single iPython cell, or if run with plt.ioff() in a regular Python REPL and followed by plt.show(), I get the same bad result as the first example above (with shrink=True in the outer function).

How can I get the correct result while still doing the colorbar resizing inside the function (instead of in userland)?

Projection of a polytope along 4 orthogonal axes

Consider the following problem:

Given an $$\mathcal{H}$$-polytope $$P$$ in $$\mathbb{R}^d$$ and $$4$$ orthogonal vectors $$v_1, …, v_4 \in \mathbb{R}^d$$, compute the projection of $$P$$ to the subspace generated by $$v_1, …, v_4$$ (and ouput it as an $$\mathcal{H}$$-polytope).

I know that the problem of computing projections along $$k$$ orthogonal vectors in NP-hard (if $$k$$ and $$d$$ are part of the input), as shown in this paper. But does it help if $$k$$ is a constant? Specifically, does it help if $$k \leq 4$$? Do we have a polynomial algorithm in this case?

Select 4 points of $n$ in 2d to make rectangle with the greatest area and sides parellel to the axes

On the plane $$n$$ points $$(x_i, y_i)$$ are marked. Select 4 points so that they define a rectangle with the greatest area and sides parallel to the axes.

Time limit for python is 10 seconds, for other programming languages – 2 seconds.

Input data:

• in first string integer $$n$$, $$(4 \leq n \leq 3000)$$
• in next $$n$$ strings pairs of integer coordinates $$x_i\ y_i$$ $$(-10\ 000 \leq x_i,\ y_i \leq 10\ 000)$$

Output data:

• 4 different indices (numbers from $$1$$ to $$n$$), specifying the vertices of the rectangle.

I made in python, but even with tests of $$n \leq 111$$ it have TL.

n = int(input()) l = [] for i in range(n):     a, b = map(int, input().split())     l.append((a, b))  ans = [1, 2, 3, 4] mS = 0  for i in range(0, n - 3):     for j in range(i, n - 2):         for k in range(j, n - 1):             for t in range(k, n):                 r = [l[i], l[j], l[k], l[t]]                 w = sorted(r, key=lambda element:(element[0], element[1]))                 if w[0][0] == w[1][0] and w[1][1] == w[3][1] and w[3][0] == w[2][0] and w[2][1] == w[0][1]:                     s = (w[1][1] - w[0][1]) * (w[3][0] - w[1][0])                     if s > mS:                         mS = s                         ans = [i + 1, j + 1, k + 1, t + 1]  ans = sorted(ans) print(ans[0], ans[1], ans[2], ans[3])  `

I need to draw additional X axes in chartJS

I have ~200 points in my line chart and I need to put the calibaration lines in the chart too, so maximal and minimal possible value lines. Right know I’m putting 3 datasets- one with the value, one filled with the minimal and maximal values. Can I somehow draw a line in the chartJS that is not a dataset?