figure

How to draw a triangle using matplotlib.pyplot based on 3 dots (x,y) in 2D?

家住魔仙堡 提交于 2019-11-29 22:57:56
问题 I would like to draw a triangle using python3 module matplotlib. import numpy as np import matplotlib.pyplot as plt X_train = np.array([[1,1], [2,2.5], [3, 1], [8, 7.5], [7, 9], [9, 9]]) Y_train = ['red', 'red', 'red', 'blue', 'blue', 'blue'] plt.figure() plt.scatter(X_train[:, 0], X_train[:, 1], s = 170, color = Y_train[:]) plt.show() It displays 6 dots but they are grouped separately in 2 places. (color helps to see it clearly) There are 2 sets of 3 dots. I want each set(3 dots) be united

python check if figure is 2d or 3d

不问归期 提交于 2019-11-29 16:43:35
In matlab with a figure, to check if it is 3D figure or 2D figure I use: V=axis; and check the number of components of V (4 for 2d figure, 6 for 3d figure). How can i implement this with python and matplotlib? ImportanceOfBeingErnest You can use the name of the axes. plt.gca().name or ax.name if ax is the axes. A 3D axes' name will be "3d" . A 2D axes' name will be "rectilinear" , "polar" or some other name depending on the type of plot. You can therefore check if ax.name == "3d": # axes is 3D, do something else: # axes is not 3D, do something else You can also check for the limits, as

html5, figure/figcaption inside a paragraph gives unpredictable output

故事扮演 提交于 2019-11-29 14:22:32
问题 The following markup uses the figure element to display an image, inline with the text of a paragraph -- hence the figure is 'included' inside the first <p> . <div class="object-content"> <p> <figure class="object-inline-figure"> <img class="object-inline-figure-image" height="200" src="/site_media/media/files/images/WH-487_opt.jpeg" width="300"> <figcaption class="object-inline-figcaption"> <p class="object-inline-figcaption-caption">Lorem ipsum dolor sit amet, consectetur adipiscing elit.<

How to superimpose figures in matplotlib

前提是你 提交于 2019-11-29 11:42:24
I create several figures in multiple modules, and i would like to superimpose them in my main.py . Can i return a usable figure/plot that could be reused in main.py to create a combined figure? Thanks! The solution is to setup a figure/axis in main.py and then pass the axis handle to each module. As a minimal example, import matplotlib.pyplot as plt import numpy as np #from mod import plotsomefunction #from diffrentmod import plotsomeotherfunction def plotsomefunction(ax, x): return ax.plot(x, np.sin(x)) def plotsomeotherfunction(ax, x): return ax.plot(x,np.cos(x)) fig, ax = plt.subplots(1,1)

Second subplot disappearing

≡放荡痞女 提交于 2019-11-29 10:37:34
I have a weird (and probably simple to solve) problem. I tried to plot (using panel) two plots: a1 = subplot(2,1,1, 'Parent', handles.cpd_plot, 'Position', [0.1, 0.4, 0.85, 0.45]); a2 = subplot(2,1,2, 'Parent', handles.cpd_plot, 'Position', [0.1, 0.1, 0.85, 0.15]); but after plotting a2, a1 disappears. I see that its some problem with position, when I lift up a1 a bit ( 'Position', [0.1, 0.5, 0.85, 0.45] ) its working (but it has to be >= 0.5). Where is the problem? Thanks! So it is probably happening because subplot deletes a plot when it is overlapping with the previous plot. I suspect that

How to change font size of x axis? [closed]

别来无恙 提交于 2019-11-29 08:18:05
Is there any way to change the font size property of x axis in MATLAB for a figure? I need to change the size of the values in x axis (not the title, that one could modify with xlabel property). I have the next piece of code: %% Some figure properties: width=15;height=20;alw=0.75; %% Figure: for i=1:8 figure;set(gcf,'color','white'); pos=get(gcf, 'Position'); set(gcf, 'Position', [pos(1) pos(2) width*100, height*100]); set(gca, 'LineWidth', alw);axis off; axes('position',[0.06 0.08 0.87 0.38]) plot(0:24,s(i).obs(:,1),'linewidth',2,'color','b');hold on; plot(0:24,s(i).sim(:,1)-273.15,'linewidth

Interactive(?) plotting in Spyder with matplotlib

陌路散爱 提交于 2019-11-29 01:41:28
I am trying to migrate over to Python from Matlab and can't figure out how to get interactive(?) plotting working within the Spyder IDE. My test code is shown below. With the .ion() nothing happens, I get a quick flash of a figure being drawn then the window instantly closes and spits out my Hello. Without the .ion() the figure is drawn correctly but the script hangs and doesn't spit out Hello until I manually close the figure window. I would like the script to run like a matlab script would and plot the various figures I ask it to while chugging along any computations and putting the output

Problem with float and pictures in LaTex

☆樱花仙子☆ 提交于 2019-11-29 00:28:36
The picture is at the position of the header: http://dl.getdropbox.com/u/175564/%20latex1.png Code: \begin{figure} \subfloat[A gull]{\label{fig:gull}\includegraphics[width=0.15\textwidth]{p1.png}} \subfloat[A tiger]{\label{fig:tiger}\includegraphics[width=0.15\textwidth]{p2.png}} \caption{Pictures of animals} \label{fig:animals} \end{figure} Code before \begin{document}: \documentclass[12pt,a4paper, notitlepage]{article} \usepackage[english]{babel} \usepackage[latin1]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage{amsthm} \usepackage

Subfigs of a figure on multiple pages

我是研究僧i 提交于 2019-11-28 23:36:25
问题 I am facing problem of stacking many figures The problem is the stack figure is overriding the page dimension vertically and placing all the figure in one page and not changing the page as the limitation of page is reached. How can page be changed while stacking all the figures. \usepackage{subfig} \usepackage{float} \begin{figure}[hp] \centering \subfloat[Fig1]{\label{fig:1}\includegraphics[width=0.48\textwidth]{fig1}} \subfloat[Fig2]{\label{fig:2}\includegraphics[width=0.48\textwidth]{fig2}

Plot Overlay MATLAB

好久不见. 提交于 2019-11-28 20:41:13
How do you take one plot and place it in the corner (or anywhere for that matter) of another plot in MATLAB? I have logarithmic data that has a large white space in the upper right-hand side of the plot. In the white space I would like to overlay a smaller plot containing a zoomed in version of the log plot in that white space (sort of like a magnified view). Before you tell me it can't be done, I would like to mention that I have seen it in action. If my description is lacking, just let me know and I'll attempt to better describe it to you. An example: x = 1:20; y = randn(size(x)); plot(x, y,