How to merge two plots on the same graph? - python-3.x

I have two graphs: one is the list of each day in 2018 (datetime object) on x-axis with its corresponding value on y-axis, the other one is the list of each week in 2018( 52 in total) on x-axis with its corresponding average value on y-axis.
I was asked to merge two plots on the same graph. However, if I set both domains to be days in 2018, the latter graph goes wrong and following shows up
ValueError: x and y must have same first dimension, but have shapes (365,) and (52,)
What should I do to get the things sorted out? Many thanks in advance.

Related

How do I graph scalable data on both the x and y axis of a bar chart in Excel?

I am having issues creating a Bar graph in Excel. Currently, the Y-axis is a 'series' value input allowing for salability whereas, the x-axis is a 'categorical' input. I am trying to graph the 1st year earnings (y-axis) for each major at two Universities(UF-USF) with the number of graduates at the universities on the x-axis. I'm using the same population data for both so the columns overlap and can compare degree earnings between the universities. I managed to create a graph that has a "scaled" x-axis but, it's still categorical data so I cannot manipulate it- Figure 1. I want to make it look like Figure 2 while displaying the disproportionate number of graduates per the three degrees on the far right. I've already considered other graphs but must have a bar chart.
Figure 1: 'Scaled horizontal axis with Categorical input
https://gyazo.com/8e8d97bc2696113071d487ed96212b61
Figure 2: Overlapping University Bar Chart(Categorical X-axis)
https://gyazo.com/f1fbdebee4b1c4df27471c812d04da0e
Figure 3: Alternate Bar Chart without University Overlap (Categorical X-axis)
https://gyazo.com/3ed448c369827c0dd056fc151444df06
Figure 4: Data
https://gyazo.com/73ace8e16f481b5776a333911084b8a1
The 1st year, 5th year and 10th year earnings are in the data set. Until this is figured out, I'm only graphing 1st-year data.
Thank you!

How to set different horizontal (category) labels for each different product in MS Excel line chart

I am plotting a line graph for 3 different products in MS Excel. The x axis is revenue and the y axis is cummulative p/l. The problem is that when I set the horizontal (category labels) for each of the products (series), it also sets the same range for the two remaining products. The range for the horizontal axis for the last product that i set, modifies the horizontal ranges for the rest. The output (chart) that i get shows all lines reaching a maximum of that x value for the last set product.
Please advice me.
Thank you
A line chart has a categorical X axis. It can also use dates, but I'm not even sure if Excel 2007, which you are using, has that feature or if that came later.
In a category axis, the values of the cells don't matter. They are all in the same position.
If you want to plot the X axis points based on their value, you need to create an XY Scatter chart instead of a line chart.

Change order of x values in Excel (VBA)

I am trying to make a plot of values collected on weekly basis over a period that stretches from one year to another. However, I can't figure out how to manipulate the order of the x-values of the plot when feeding the following values:
Weekly data for category A and B
The resulting graph looks like this:
Resulting plot
What do I need to do in order to change the sequence so that week 1 and 2 follow after week 52 on the x-axis?

Dynamic Milestone Trend Analysis Graph needs same y-axis as x-axis in Excel with VBA

After a couple hours of work I come to you guys with this graphing problem. I need to create a Milestone-Trend-Analysis which can be seen on the german wikipedia , though not in the english version.
General Information
In short, the diagram has report dates on the x-axis (for now, on every first of the month, another report is due).
The y-axis should mirror the x-axis completely. In length and also the tickmarks. The dates get bigger from the bottom to the top.
In my case the x-Axis is on top of the diagram.
Every report consists of a number of "due-dates", one for each assignement in progress. They are the estimated "finishing dates" of that particular assignement.
If the estimated finishing date stays the same in the next report period, the graph for that assignement stays on the same level. If the estimate is earlier, the graph trends down. Normally they go up, since the assignement has some delay :-D
The x-axis needs to be dynamic, since the whole project is basically finished when its last assignement is finished. If one of the assignements is running late, the whole project gets delayed an thus the x-axis needs to be longer/get more ticks.
Since the y-Axis mirrors that, it has to change too.
MY PROBLEM
The x-axis has a number of discreet values, since the reports come in every month, or every two weeks. But that does not change.
The values for the finishing dates are continuous, since the assignements can be terminated whenever.
That leaves me with the problem of having to cut the y-axis in equal-size chunks, although the months of the year are not equal in size. At least that is, what I think excel forces me to do.
I can assign a max limit and a min limit for the y-axis and I can assign a distance between each main tickmark. Since Excel works with a continous number for each date, the 2014/01/01 would be 41640. And 2015/01/01 is 42005. Since I have 12 month on the x-axis and I need 12 on the y axis, I would have to have the main Ticks at a distance of 30.42 ... which gives me the following Months on my axis
January January March .... December December
Does anyone know an answer for this? Is there a way to have excel make the tickmarks on the y-axis not equal distance?
Any input greatly appreciated.
Kaz
I did not find a way to make Excel have variable tick mark distances. But since I coud not have it that way, I had to make the month equally long.
This works for me now:
'calculate the norm for different type of month including Schaltjahr
Select Case cellMonth
'February
Case 2
'Schaltjahr and Schaltjahrhundert
If (cellYear Mod 4 = 0) Or (cellYear Mod 400 = 0) Then
resultDay = (30 / 29) * cellDay
Else
resultDay = (30 / 28) * cellDay
End If
'31 day months
Case 1, 3, 5, 7, 8, 10, 12
resultDay = (30 / 31) * cellDay
'30 day months
Case Else
resultDay = cellDay
End Select
Now I just have to scale the axis to numberOfMonths * 30. It now leaves adjusting the names of the y-Axis, which seems to be a whole different story.
Kaz
You can put arbitrary labels along the Y axis by adding a dummy XY series.
Here is some data that I think captures your issue, plus a line chart showing the data, plus the data that I'll use to construct a dummy Y axis.
I used a line chart so the X axis at least would be easy. You just have to make sure that the axis is formatted as a date axis with Base Unit of Days.
Here is how I built the axis.
Top Left Chart Below: I copied the dummy axis data, both columns of the data includingt the header row. I selected the chart, and used Paste Special to add the data as a new series, data in columns, series names in first row, categories in first column (but don't replace existing categories).
Top Right Chart Below: I right-clicked on the added series, clicked on Change Series Chart Type, and selected XY Scatter with Lines and Markers. Excel also put this series onto the secondary axes.
Middle Left Chart Below: I formatted the added series to be plotted on the Primary axis.
Middle Right Chart Below: I changed the scale of the vertical axis, giving it a minimum of the first date and a maximum of the last (1/1/16 to 9/1/16).
Bottom Left Chart Below: I formatted the vertical axis to show no labels.
Bottom Right Chart Below: Format format format. I formatted the dummy axis series so it used light gary lines (matching the horizontal axis) and light gray cross markers (simulating tickmarks). I changed the tickmarks of the horizontal axis so they crossed the axis, matching the cross markers of the dummy series. I added data labels to the left of the dummy series points, simulating vertical axis labels.

Highlight points on an Excel Line Graph according to a list

I have 2 data series, which records how much a user is meditating/attentive (out of 100) plotted onto a graph. The x axis is the number of seconds since the start of the experiment, and the y axis shows the value for meditation/attention at that point of time.
I have a 3rd set of data that is a series of key timestamps during the experiment (not exactly matching the timestamps from attention/meditation values).
I want to create a graph where you can compare how the attention/meditation values change at the key points
Whether the key points are highlighted by a line or dots I don't care. I tried adding the 3rd data set as a secondary axis, but it still uses the original x-axis of the main graph and I don't know how to make excel do what I want.
Thanks in advance
You should use an XY Scatter chart, not a line chart. A line chart ignores any numerical value in the X values, treats each X value as a text label, and uses the X values from the first series as X values for all series.
You can format the first two series so that they use lines and not markers, and the third so it uses markers without lines.
You may find this link helpful: superuser.com/questions/825692 You don't need to use the secondary axis, just add another series with tag times and constant 45 value, then format vertical error bars to 100% and horizontal to 0%.

Resources