plt.xticks automaically show up to 3 digits - rounding

I am creating subplot (10x10). Some of the xticks or yticks show long numbers, up to 6 digits after comma (0.0023444477 etc). How can I automatically set up tick up to 3 digits after comma, so all ticks are 0.00x? I have different ranges for each plot.
Thanks for any help

Related

How to make a categorical count bar plot with time on x-axis

I want to count the number of occurrences of categories in a variable and plot it against time.
The data looks like following:
Date_column Categorical_variable
20-01-2019 A
20-01-2019 B
20-01-2019 C
21-01-2019 A
21-02-2019 A
22-02-2019 B
........................
23-04-2020 A
I want to show that in month of Jan I had 1 occurrence of B/C whereas 2 occurrences of A. In feb, I had 1 occurrence of A/B and so on. The bar plots can be stacked to know the total number of occurrences.
I've been very close to it. But haven't been able to draw plot out of it.
df['Date_column'].groupby([df.Date_column.dt.year, df.Date_column.dt.month]).agg('count')
The other way is to change the dates to 1st of every month, and then group by to count a occurence. But I'm unable to draw plot out of it.
df.groupby(df['Date_column'], df['Categorical_variable']).count()
Use crosstab with Series.dt.to_period:
df['Date_column'] = pd.to_datetime(df['Date_column'])
df = pd.crosstab(df['Date_column'].dt.to_period('m'), df['Categorical_variable'])
df.plot.bar()

Add horizontal axis per series in excel

How frustrating is Excel.. working on this for half an hour now.
I simply try to make a frequency plot of two groups, with different colours. On the x-axis I would like to display the subject.ids per bar.
However, if I select a different range for the horizontal x axis per series (series 1 = blue, series 2 = orange) with the subject id, it changes the x-axis in the other series to the same. What in hell am i doing wrong?
3007 1
23121 1
3009 1
3005 1
3011 2
23171 2
3207 2
3102 3
3207 6
13302 7
2411 11
23191 11
3008 11
3106 12
110031 1
110031 1
110030 1
110017 1
110014 1
110008 1
110004 1
110007 2
110035 4
110020 4
110003 4
110036 10
110019 11
110015 21
AFAIK, you cannot put 2 series onto the x axis.
You have 2 alternate ways to solve your problem:
Concatenate each positional pair into a new column and use this as the x-axis label series. It will look like this:
You could use data labels for each series. However, this will add the data to the columns themselves and not the axis (you could put it at the base of the column). To do so, you will need to right click on the graph, select 'Add Data Labels'. By default it adds the value as the label, but you can select the labels, right click to format the data labels and use the 'values from cells' option. Once you do this and play around with the orientation and location of the labels, it will look like this:
For simplicity, I'd go with the first method
Adding a 3rd option; simply put the columns for the axis labels beside each other and when selecting the Data for the Axis Labels, just select both columns instead of the usual 1. It will look like this:

how to put the different times in y axis in matlab

greeting for every one,
I have data in excel file and i want to draw a plot in Matlab in which the Y axis represent the time with starting time in 10:45 for 24 hours i.e, from 10:00 am to the next day in 10:00 am. The x-axis represents the excel file data( the values of frequencies during 24 hours)
how to put the different times in the y axis showing the values of time in the formula of time(00:00 am/pm) using matlab?
if i use this code: ylim(subplot2,[1 24]) and xlim(subplot2,[170 230]) it will be plotted but the y-axis shows only the hours from 1 to 24 hours and i need the y-axis from 10:45 am(starting time) to(10:45)am in interval 24 hours
You can create custom tick labels by specifying tick strings with the command:
time_cells = {'10:45','11:45',...,'9:45','10:45'};
set(gca, 'YTickLabel', time_cells)
Where gca is the handle of your current plot (axes), and the time_cells is a cell array containing all your required tick labels (without the ellipse). It is probably easiest to generate this using a for-loop to create the numbers you want, and then num2str to convert to the strings you need.

excel chart different spaces between values on OX

trying to make line chart using data
X Y
1 12
3 34
5 56
6 68
9 79
14 98
is it possible to make different spacec on the horrizontal axis?
because now there are same between 1 and 3, 9 and 14 etc..
As Tim Williams stated in his comment, which he should have made into a full-fledged answer:
Use an Excel XY (Scatter) chart. A line chart treats X values as non-numeric labels, while the XY chart treats both X and Y as continuous numeric variables. The lines and markers in XY and Line charts can be formatted the same.
To create a bar chart with differently spaced bars, insert empty rows between your x, y pairs so that the spacing of the data in the rows reflects the distance between the x points. For example, if the [1, 12] pair is in cells A1:B1, place the [3, 34] pair two rows down, in cells A3:B3; [5, 56] would go in A5:B5, etc.
This may produce bars that look too narrow. You can increase the width of bars by first left-clicking on one of the bars to select them all, and then right-clicking and selecting Format Data Series. The second slider in Series Options will change the bar width for the chart.

Creating a scatter-plot with series from row values, and XY values from two other rows

I am doing a project that requires me to study the several condition that affect GPS accuracy, and after I collected a set of data and dumped it to Excel, I was trying to plot a scatter graph, grouping the data into different series according to a value: in this case, I wanted to plot the Latitude and Longitude values as the XY scatter values, and separate the series by the number of satellites when the fix was obtained.
Timestamp Latitude Longitude #Satellites
133009.279 3839.3354 904.7395 0
133010.279 3839.3354 904.7395 0
133011.279 3839.3354 904.7395 0
133026 3845.9863 907.4513 4
133027 3845.986 907.4491 4
133028 3845.9851 907.448 4
133222 3845.9909 907.4866 4
133023.28 3845.9817 907.4429 5
133024.28 3845.9867 907.4549 5
133048 3845.9868 907.452 5
133205 3845.9929 907.4858 5
133206 3845.9927 907.486 5
133207 3845.9925 907.4862 5
133056 3845.9885 907.4569 6
133057 3845.9881 907.4578 6
133223 3845.9905 907.4868 6
133224 3845.9901 907.487 6
I have tried selecting the three rows, adding the series afterwards by selecting the appropriate row, and even tried pivot tables, but these don't allow for scatter-plots unfortunately.
All this to no avail, but I am positive that you can plot the graph. Does anyone have an idea?
PS: Manually selecting the series myself isn't an option, since there is a large number of data. If I could select all of the data for one specific value in a row, though, would let my select each series, and I think I would be able to make it from there.
Have a look at the XY charts from FusionCharts XT - http://www.fusioncharts.com/demos/gallery/#bubble-and-xycharts

Resources