While plotting some time series data I ran into an issue. With 2/15 of my plots I got these weird black marks showing up next to them in Jupyter Notebook.
I tried re-running those specific plots in a normal .py file and I got the same results. So I tried plotting it in Excel instead.
Clearly, these plots are totally different. So something must be messing with the data when it runs through Matplotlib somehow. It looks inverted but not all of the peaks seem to be there. It is strange.
Unfortunately, I can't share my dataset. But I'm wondering if anyone has seen this before and could give me an idea of what is causing this. Because as I mentioned, 13/15 of my plots work perfectly as expected, and the code is the same.
Related
A project I am working on requires me to put multiple plots in one figure as in 100+ plots in one figure and the dataset I am working with currently has exactly 100 plots. I am using Jupyter to test code then putting finished code into Visual Studios 2019. In Jupyter I am able to plot about 80 lines in one figure before the figure becomes distorted. It is the same in Visual Studios. At 90 lines, the figure cuts off about half of the plots and at 100 the programs crash. I was told I likely need a more powerful computer since I am just using my regular hp laptop, but I was wondering if there is a way around this or is that my only option?
For instance, maybe I could make two figures with 50 plots each then merge the two but I'm not sure if that would also crash the programs. Although that might also be a problem when the datasets contain something like 400 plots each. I am afraid any solution will be far over my head as I'm relatively new to Python.
For reference I added what the figures look like with 40 and 90 plots.
figure with 40 plots
figure with 90 plots
Based on your examples, I assume you mean you want to put many lines onto one graph, so I think this is a duplicate of: plotting too many lines in matplotlib: out of memory
The solution you want is probably using a Line Collection to pass in many lines at once.
I'm working on Jupyter notebook now, just learned to open a csv file with pandas.
However the guy in the video (who explains how to do it) has grids to separate things:
Here are screenshot of his screen and mine respectively:
I hope you understood what I meant, you'll see that grids are missing, I'm just curious where they are. It might not effect my work at Jupyter, but still however.
I often use fill_between() to represent the error on my time series plots and save them as pdf files (using plt.savefig()) which I then insert into either PowerPoint presentations, or MS Word files. I've personally never had any issues in seeing the plots. However, recently, a couple of instances occurred where others could not see the specific plots generated by the fill_between() function. The other plots in the figure were visible without issue.
I wonder if anybody else has had this issue, and any possible solution for this. Would saving as a .png file ensure that the shaded regions always show up?
Thanks
EDIT: The persons who cannot see the shaded regions due to fill_between() are anonymous reviewers of my research paper, hence its not possible to go communicate with them to investigate if the problem is in their systems or mine. Rather, my question is more generic and not situation-specific. Once a plot is saved (in this case, as a pdf), I didn't expect it to change.
An example of fill_between() in my code:
def plot(ts,err,Label,col,sty):
plt.plot(ts.index,ts,col,linestyle=sty,linewidth=2, label=Label)
plt.fill_between(ts.index,ts-err, ts+err
, alpha=0.15, edgecolor=col, facecolor=col)
plot(dataTs,err(dataTs),'label','k','-')
plt.savefig('../Figures/test.pdf', bbox_inches='tight')
Output plot:
The machine and the OS that I use: Macbook Pro, macOS Sierra.
I’ve been working on bokeh plots and I’m trying to plot a line graph taking values from a database. But the plot kind of traces back to the initial point and I don’t want that. I want a plot which starts at one point and stops at a certain point (and circle back). I’ve tried plotting it on other tools like SQLite browser and Excel and the plot seems ok which means I must be doing something wrong with the bokeh stuff and that the data points itself are not in error.
I’ve attached the images for reference and the line of code doing the line plot. Is there something I’ve missed?
>>> image = fig.line(“x”, “y”, color=color, source=something)
(Assume x and y are integer values and I’ve specified x and y ranges as DataRange1d(bounds=(0,None)))
Bokeh does not "auto-close" lines. You can see this is the case by looking at any number of examples in the docs and repository, but here is one in particular:
http://docs.bokeh.org/en/latest/docs/gallery/stocks.html
Bokeh's .line method will only "close up" if that is what is in the data (i.e., if the last point in the data is a repeat of the first point). I suggest you actually inspect the data values in source.data and I believe you will find this to be the case. Then the question is why is that the case and how to prevent it from doing that, but that is not really a Bokeh question.
While there are a few things that are still being worked out, I am a big fan of the LightTable editor. The IPython Notebook is a remarkable delivery system, but managing a larger product is a bit easier in a more conventional development environment.
One thing that I have not yet figured out, however, is complicated plotting in LightTable. With no cell equivalent, I am not sure how to modify plot components because each command seems to be considered independently. In particular, I am not clear on how to work with subplots. I am unable to connect the actual plot to the subplot array. For example, consider the following:
fig,ax=plt.subplots(2)
ax[0].hist(np.random.uniform(size=100))
ax[1].hist(np.random.normal(size=100))
When I create the subplots, they show up empty inline. The remaining code, however, does not cause them to update inline. In the Notebook, all the code is considered jointly in batch. LightTable interactivity is a bit closer to dealing with an interpreter in interactive mode (even though the script is obviously preserved). I have experiemented with turning interactivity on and off via plt.ioff(), but to no avail. Any assistance would be greatly appreciated...