This question already has answers here:
How to overlay plots from different cells?
(1 answer)
How to add plot commands to a figure in more than one cell, but display it only in the end?
(1 answer)
Closed 4 years ago.
I'd like to have this code organization
# 1st cell showing my intentions
plt.plot(t, f(t))
(NO OUTPUT)
and
# 2nd cell with boring details
plt.xlabel(...)
...
plt.show()
(the plot with all the now interesting details)
because I plan to use the notebook to produce slides and/or pdf using an extension that allows to hide the input cell only, so that my reader sees only
what I want to show of my code — they can look at the notebook itself to see what's going on behind the scene…
I've tried plt.hold() but it's not what I had in mind…
Related
This question already has answers here:
Python openpyxl data_only=True returning None
(7 answers)
Closed 1 year ago.
I am not able to print the computed cell value with this option. it is printing the formula instead of cell value.. can someone please help me on this.!!!!!!!!!!!!!!!!
sheet['L3'] = '=COUNTIF(B1:B431,"Resolved")'
now I want to print the L3 cell value to the screen
Python openpyxl data_only=True returning None
According the this thread, the formula needs to be evaluated by Excel before having its value cached.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Working on a vendor's sales document provided by a grocer, which lists the number of units they sold. Issue is that their excel sheet and the way they record sales (which I cannot change) doesn't differentiate between single bars sold and boxes sold - so some rows state "Mint Bar" = 1 sold and some state "Mint Bar Box" = 1 sold. The unit values are the same in the sheet, but the "box" should really = 12 (since a box is 12 units, not just 1).
The second issue is that every time "box" appears that value needs to be n*12 (so 1box*12 = 12 bars).
Thus, I am looking for some code to help me out. I know this is easy in SQL and have less experience running excel macros.
--
Fixed:
Where the Boxes appear in D2, D6, D8, etc:
=if(Cell="Box", 12*D2, 12*D6, 12*D8)
Drag formula down for all the rows in the sheet.
do you have to do this in a macro? I would just add another column that says
=if(Cell="Mint Bar Box", 12, 1)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Files here
Hello,
I am trying to write code to format a report. The main issue with the report is that some cells store multiple pieces of data in a cell when each row should only have one piece of data in each cell. My solution thus far has been to use the text to columns function for the affected cells, paste all other data transposed, and finally copy and re-transpose the new data over the original report area. This has worked so far, but I am running into an issue with cells that store time. Cells with single times (such as 13:00) are in the custom format hh:mm, which vba converts to a a decimal number. Cells with multiple times (such as 11:009:008:0010:30) are viewed as a string.
The code I am currently using to split the times works for multiple time cells because it searches the string for ":", but vba does not detect the ":" in the custom format cell 13:00 since internally it sees that cells value as something like 0.56412.
I am kind of at a loss as to what to do here. I can't change the format that the report arrive to me in. My thought was that maybe I could find a way to turn the custom format "13:00" into a string "13:00" instead of 0.56412
I have attached the code file and the truncated dummy report I am testing to code on. I would like to thank everyone who responds for their help in advance!
to change a single time to a string, you can use format and identify the value to excel as a string using '
example:
'immediate window
[a1]="'"&format([a1],"hh:nn")
'or, using a range
range("A1")="'"&format(range("A1"),"hh:nn")
you can use isnumeric to check if it's a single time. True means it's a time, False means it's a string of times
I have one question to the line chart.
I would like to create a line chart, which values are given. It should look like this chart here:
My question is, how can I implement this. I tried to put it as a stripline in the chart but it only shows a horizontal line without this steps at the beginning.
How can I create this line chart like in the picture above?
can I put into this:
the values.
Striplines are intended to display just a line across the chart, or varying width, height, to demonstrate an area... from MSDN
Strip lines, or strips, are horizontal or vertical ranges that shade the background of the chart in regular or custom intervals
To get the behaviour (I think) you require you can add a new series to the data you are returning with each of those datapoints. Irrespective of what other data you are charting, you can change the type of this series to Line Chart, and change the order of the series on teh chart to make it uppoermost.
Without further information - such as the data you are tyrying to superimpose this on - it's hard to advise further.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
My idea is to use Userform to create graphs in excel. The userform would have two drop down lists: one is for y-axis and the other one is for x-axis. I want the userform to create a graph with chosen y and x axises in excel.
So far, I know how to make userform with drop down list. I need help to get started to do the rest. I don't know what to do next. Please a link to a tutorial of this similar project or ideas of how to do this would be a great help!
This is a short guide how to start.
Prepare data for charts
For the start I'd suggest to assign names (Define name) to ranges with data and create data validation with exact same names as it was assigned to ranges. (In the code bellow the user chooses x in A1 and y in A2, a list of choices could be: Height, Weight, Age).
Create an empty scatterplot chart
Sub CreateXYchart()
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatter
ActiveChart.SeriesCollection.NewSeries
End Sub
Update X and Y values with a macro
Sub ChangeXY()
vXCell = "A1" ' Where the user chooses x
vYCell = "B1" ' Where the user chooses y
vChartName = "Chart 1" ' Chart name of XY Scatterplot
vRangeNameForX = ActiveSheet.Range(vXCell).Value
vRangeNameForY = ActiveSheet.Range(vYCell).Value
ActiveSheet.ChartObjects(vChartName).Activate
ActiveChart.SeriesCollection(1).XValues = Range(vRangeNameForX)
ActiveChart.SeriesCollection(1).Values = Range(vRangeNameForY)
End Sub
You could create a button to run a macro. So this is for the start (code assumes that everything is on the same sheet, btw). Have fun.
I dont if i got your question try this tutorial ,
Charting
Is a very a good tutorial from a very good website , i recommend for charting and general Excel.
If this isn't what you looking for, tell me !
Good luck !