323 questions
1
vote
1
answer
69
views
How to limit the number of displayed xticks in pyplot when x values are strings
I have a scatterplot in pyplot where the x-values are necessarily strings. Is there an easy way to limit the number of xticklabels that pyplot will show?
I am not referring to specifying the xticks ...
2
votes
2
answers
87
views
How to create same ticks and labels on both axes?
I have to create a plot on which ticks and labels are specifically defined; an example of reproducible plot is given below:
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('seaborn-...
0
votes
0
answers
156
views
How to use plot.formats.multiple-of in Typst cetz-plot
I am plotting some functions in Typst with the cetz-plot package.
#import "@preview/cetz:0.3.4": canvas
#import "@preview/cetz-plot:0.1.1": plot
#set page(width: auto, height: ...
0
votes
1
answer
114
views
Can you change the default tick density when creating a matplotlib plot?
When you create a plot with matplotlib.pyplot (plt), and call the grid with plt.grid(), from what I understand a call is made to plt.Locator class. I was wondering if there is a simple way, through ...
0
votes
1
answer
83
views
Can't Align Histogram Bin Edges with Chart Even When Using Numpy histogram_bin_edges
I want the histogram edges to line up with the xticks of my chart. Other SO and answers I've read focus on calculating the bins and passing them. I've done this yet still can't get them to align:
I'...
1
vote
2
answers
183
views
For multi-index columns in pandas dataframe, how can I group index of a particular level value for visualization in Python?
I have a pandas dataframe which is basically a pivot table.
df.plot(kind = "bar",stacked = True) results in following plot. The labels in x-axis are congested as shown.
In Excel I can group ...
0
votes
1
answer
84
views
Matplotlib logit scale tick number formatting
When using the log scale with matplotlib, we can set globally with (see this answer)
import matplotlib.pyplot as plt
plt.rcParams['axes.formatter.min_exponent'] = 3
that ticks on logarithmic axes are ...
0
votes
1
answer
50
views
Controlling tick marks and lines in chart.js time scatter plot
Concerning this jsfiddle which uses chartjs v3.9.1 and the date-fns adapter:
https://jsfiddle.net/0a6c1ty5/22/
I'm trying to format the tick labels in the function tick_label but I'm only getting a ...
0
votes
0
answers
99
views
missing xaxis ticks with plotly
I have a pandas dataframe with hourly data shown in 7 subplots for a weeks data.
fig = make_subplots(
rows=7,
cols=1,
subplot_titles=subPlotNames,
shared_xaxes=True,
shared_yaxes='...
0
votes
1
answer
46
views
How to shift ticks and labels in-between grouped boxplots with a discrete x scale using ggplot2?
Surely already asked, but I'm struggling to find a clear solution that fits my case.
How to shift ticks between grouped boxplots (rather than centered on them) so that to define hours intervals?
...
2
votes
2
answers
312
views
How to display axis tick labels with a detailed scientific notation offset?
I am trying to produce a figure with multiple subplots where the axis tick labels of each subplot should be formatting in the same way. As the numbers are large, displaying tick labels in a legible ...
1
vote
3
answers
103
views
Pandas plot - unable to set xticks
I am trying to plot a stacked bar chart using pandas dataframe plot method. The x values are floats and I am trying to set xticks at integer intervals with no success. Here is my code
import pandas as ...
2
votes
2
answers
220
views
How to invert the direction of a single axis tick in matplotlib?
I'd like to invert the direction of a single axis tick (and its label) along the x-axis to highlight some specified value.
I was successful in manipulating other attributes but apparently inverting ...
0
votes
0
answers
74
views
plotly - replace first and last yticks with min and max value
I would like to mark max/min value as yticks like below:
import plotly.graph_objects as go
import pandas as pd
import plotly.express as px
def save_fig(fig,pngname):
fig.write_image(pngname,...
0
votes
1
answer
89
views
How to stop x tick labels from crossing x axis?
My x tick labels are crossing the x-axis into the chart area and I don't want them to, an example:
Another oddity is my x axis ticks stopped showing.
I've tried:
making ticks visible and,
adjusting ...
0
votes
2
answers
39
views
arrange values and labels on plots xticks
plt.plot(neighbors, train_scores, label="Train Score")
plt.plot(neighbors, test_scores, label="Test Score")
plt.xticks(np.arange(1,21,1))
plt.xlabel("Number of Neighbors")...
1
vote
0
answers
62
views
Change axis ticks with shared axes [duplicate]
When I create a figure with shared axes, by default the tick labels go on the leftmost and bottom-most axes.
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots(2,2, sharex=True)...
0
votes
1
answer
165
views
ticks in seaborn dark plot
I have made a plot with sns.axes_style("dark"). I want to put ticks on this plot, in the same way that the default style has ticks. Moreover, the scale of both axes is logarithmic and I ...
2
votes
1
answer
152
views
Multiple colors of matplotlib single xtick_label
I am fairly new to Matplotlib and appreciate your help with my question:
I am looking to generate a figure that each label has 2 colors. For example, a label named 'first_color\nsecond_color', first ...
4
votes
2
answers
592
views
How to use multiple xticks/axis labels at different orientations to group together subgroups?
I have written a Python script (below) to produce a Matplotlib plot to display boxplot data grouped together by subgroups (season), groups (city), and different colors (year).
However, the group (city)...
0
votes
1
answer
78
views
Fontsize in xticks not responding correctly [duplicate]
I am trying to change the fontsize of xticks and yticks in python. The plot represents daily averages for a random location for December 2019.
My problem is that I sent set yticks fontsize to 26 but ...
5
votes
0
answers
4k
views
How can I solve "UserWarning: set_ticklabels() should only be used with a fixed number of ticks" in Seaborn? [duplicate]
I faced a warning message when trying to rotate xticks of seaborn.lineplot.
At first, I tried to run set_ticks, but ax doesn't seem to have this function. I also checked FixedLocator, but haven't ...
0
votes
1
answer
37
views
Pandas barplot is setting xticks far to the right of data when using a subset of a dataset
I'm trying to make 2 separate bar plots, one of which is a subset of the other. I can set the xticks of the full dataset just fine and get the result I'm expecting, but when I set the xticks of the ...
1
vote
1
answer
72
views
Matplotlib X axis names overlapping?
Trying to get rid of on x axis overlapping issue. I couldn't change angle of the values
# Create a figure with sharing x-axis
fig, ax1 = plt.subplots(figsize=(10, 6))
# weekly order count on the ...
1
vote
2
answers
146
views
How to manually set axis offset with custom tick labels?
Consider the plot below. Both axis have custom labels, to label the rows and columns in an imshow-plot. The problem now is that the y-axis has very large values. Ideally I'd like to manually set an ...
1
vote
1
answer
57
views
Color xticks to match color of scatter plot points
Here is my plot:
generated from the python code
import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(20, 10))
n = 70
x = [f'{i}{val}' for i,val in enumerate(np.arange(n)[::-1])]
y =...
0
votes
0
answers
213
views
Formatted xticklabels on pandas plot show as 1971 [duplicate]
I've imported data from an Excel file and I plot it with Matplotlib. If I use only default settings I get accurate results with correct tick labels, even if not formatted the way I want.
df.plot()
But ...
0
votes
1
answer
83
views
How to format bar chart yearly x-axis to not contain floats
What causes the x-axis to have Year numbers in between the bars and the 0.5 attached to the Population Year
ru = px.bar(wakel, x = "Population Year", y = "Population", color = &...
1
vote
2
answers
138
views
tick label appears with different precision due to IEEE 754 float precision [duplicate]
For example:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0.0,1.2,0.2)
y = np.arange(0.0,1.2,0.2)
labels = np.arange(0.0,1.2,0.2)
plt.plot(x, y)
plt.xticks(x, labels)
plt.show()
...
0
votes
1
answer
77
views
How to display the x-axis in as yy.m only for the first month of the year and the rest as m [duplicate]
This is my example code and output.
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
# Create a DataFrame with a date column and another column with the data you ...
0
votes
0
answers
55
views
How to set ticklabels in bold on x-axis when using usetex=True [duplicate]
I have the following small program in which I use rc("text", usetex = True) in order to allow some formatting.
I thought that the line ax.set_xticklabels(ax.get_xticks(), weight='bold') ...
1
vote
1
answer
218
views
Move x-axis to data=0 but keep tick labels at the bottom
I would like to move the line of the x-axis (with all the corresponding ticks) x=0. But the tick-labels should be positioned at the bottom of the figure, to prevent clutter in the graph.
Show axis at ...
3
votes
1
answer
116
views
How can I create xticks with varying intervals?
I am drawing a line chart using matplotlib as shown below.
import matplotlib.pyplot as plt
import pandas as pd
import io
temp = u"""
tenor,yield
1M,5.381
3M,5.451
6M,5.505
1Y,5.393
5Y,...
0
votes
1
answer
33
views
Python - x-ticks placed wrong in a bar plot
I created a bar plot/hist of categorical data and I iterated over the number of records. The problem is the x-ticks are not centered. And somehow there's a zero there that comes from nowhere!
Could ...
1
vote
1
answer
451
views
Adjusting axis’ ticks in plotting with SymPy
Here is the problem:
I have two implicit functions F and G. I am trying to find a way to plot them using SymPy.
My question is, how to adjust ticks on x- and y-axis, so I can see a crossing point of ...
1
vote
2
answers
404
views
logarithmic axis major and minor ticks
In python's matplotlib, how can I make the logarithm x-axis ticks as the attached picture shows (i.e., major ticks with labels at every 0.5 spacing from 1 to 4.5; minor ticks without labels at every 0....
1
vote
1
answer
302
views
label every other tick with ggplot ggh4x nested label
I'm trying to remove labels every other tick starting from 2, I'm unable to do this when I use nested labels with ggh4x package.
My second question: Is there a way to move "AUG" and "...
4
votes
2
answers
101
views
Plotting each tickline with individually specified color
I am trying to change the color of the ticklines in my plot, where I would like to assign the colors based on a list of strings with color codes. I am following the following approach, but I cannot ...
0
votes
0
answers
69
views
x-axis shows 1970 as the starting year of time series dates [duplicate]
The dataframe df has a datetime index ranging from 2019-12-02 to 2020-01-30 and I can plot it fine using mplfinance's plot function:
But as soon as I set the tick locators, the tick values get messed ...
0
votes
1
answer
558
views
How can you automatically format dates on the x-axis using matplotlib? [duplicate]
I've been looking all over for a way to evenly space dates using Python 3 with matplotlib, and I haven't been able to find anything that would apply to just having a list of datetime objects.
I'm ...
0
votes
0
answers
40
views
Xtick Label Shift Problem with 2 Plots Overlaid [duplicate]
I am trying to make a combined plot using seaborn boxplot and scatterplot. The problem is that my xtick labels are not aligned and I've tried many solutions. the red data values are the values that ...
2
votes
1
answer
1k
views
How to show all x-tick labels with seaborn.objects
How do I make it so that it shows all x ticks from 0 to 9?
bin diff
1 4 -0.032748
3 9 0.106409
13 7 0.057214
17 3 0.157840
19 0 -0.086567
... ... ...
1941 ...
0
votes
1
answer
107
views
Cut a figure along the x axis while retaining scale
I need to be able to compare graphs that show the progress of several variables over time. I need to do this for different cases, where the time covered is not always the same: now the data visualised ...
0
votes
2
answers
452
views
x axis tick labels are one position ahead of data points [duplicate]
I have a seaborn lineplot that shows two categories' quarterly count changes. The issue is that the x-axis labels are one position ahead of the data points. I adjusted my code, but it didn't help.
...
1
vote
0
answers
42
views
How to change x-axes interval on Chart.js 3.3.2?
I am making exchange rate chart with 3.3.2 version of Chart.js
I want to make Xticks values to this [3 months ago, 1 month ago, 1 week ago, 1 day ago] with same interval.
enter image description here
...
0
votes
1
answer
40
views
want x-ticks in the order of the values shown in array X
I have:
X = [1,5,3,4,2]
Y = [10, 14, 11, 9, 10]
plt.plot(X,Y,'o')
plots x-axis ticks from 1 to 5.
I want the x-axis to show values 1,5,3,4,2 in this order.
Is there a way?
-1
votes
2
answers
361
views
Formatting tick marks
I am trying to make my column density plot axes look like the ones on the image presented so that I can present my work alongside a previous work using similar format. I am struggling to format my ...
1
vote
2
answers
673
views
Setting xticks to the first day of the month
I´m practicing seaborn visualization with a database created from scratch.
The point is that I want to see the data from this stock market prices visualizing only the first day of the month but the ...
0
votes
1
answer
56
views
Some labels and ticks from previous plot are also there even after setting new ticks and their labels. I don't want these. .plot() method of pandas
I am plotting time series data using DataFrame.plot() method of pandas. Below is the code:
import pandas as pd
import matplotlib.pyplot as plt
import numpy.random as rn
series_dt = pd.Series(rn....
-1
votes
1
answer
58
views
Setting xticks results in only a single tick on the x-axis
I'm using the code below to produce a chart in seaborn. I have included the values for score_train, score_test and alphas so that you could replicate if you try to run my code.
alphas = [0.00000000e+...